Recent Posts

Pages: [1] 2 3 ... 10
1
Programming / Re: What to do when you feel like you've made a monster?
« Last post by Rhuan on May 25, 2017, 04:14:56 pm »
Thanks for the comments everyone, further to the above I have now got the basic functions of the battle system working, though there are several things that need more work.

I do have an issue I think with having mixed up some elements of my update/state code and render/representation code and it would probably be a worthwhile exercise to go through separating this at some point - it started with the fact that before making a battle system I made a character animation engine - call the function and it checks if anyone on screen ought to be moving, or animated in any way, makes them move if necessary, checks what frame should be showing for each person and then draws them all.

I've then used this engine (including its built in animation queue for each character) as a key aspect of my combat system - but it is both updating locations and drawing which may have a been a mistake; I then had situations such as:
- I need the characters locations updated before doing X
- but I need to draw Y before I draw the characters...

Additionally my menu code has one function to both update the menu and draw it; perhaps I should split this menu function and the character engine function each into two functions then perhaps I could make a more logical flow; I'm not sure if it will help or not though.

Actual functionality that's still needed:
1. accuracy and evasion stats need to do something...
2. techniques need to exist (at the moment it's "Attack" only)
3. the system needs to check if you've won or lost - I've not made any kind of victory/defeat handler - the only exit method is hitting escape
4. The AI needs to be a lot better...
2
Programming / Re: What to do when you feel like you've made a monster?
« Last post by Beaker on May 25, 2017, 02:44:31 pm »
I'll put some of my cents in.  I'm not sure if this will be helpful.

The first organization of code that I do is state vs representation.  The state says what is currently in the game/battle system, while the representation shows the graphics and sound.  The representation parts never modify the state, and are idempotent (running it twice gives the same output both times), and the output is determined by the state.  The last required part is the code that updates the state.  It only modifies the state based on the current state and user input.  In programming speak, this is the model-view-controller idea. 
 
Second, when making a battle system, you have to determine if you need a scripting engine or not.  In some cases you do, but most cases not so much.  In an engine it's possible to have multiple actions happen at once (for example, multiple people moving at the same time in the default map engine), but there's added complexity with the control flow.  An active battle system like FF6, should be in an engine since a monster can attack while the player is in a menu, while a turn based system like Dragon Quest can be done without one.  Without an engine, the battle loop goes through the players and enemies running the DoTurn(character) functions until victory or defeat, and the control flow is much easier to follow.  In an engine, the engine is constantly running and you're queuing events to happen n units of time later, which breaks the control flow, but is needed.  In short engines are asynchronous, so only create one if you need it.

Third, don't be afraid of globals.  You're making a game by yourself, it's not a web application.  I could give a long speech about what is a global, what is not a global, and what types of globals there are, but in short for this, the rules change according to what the program has to do and how many people are working on it.

Fourth, get a non-moving spec in place for what the battle system has to do before anything else.  Once you're fine with what you have to make, start with the most abstract layers and lay them out, and work your way down through the abstraction until you're done.



3
Engine Development / Re: miniSphere 4.5.11
« Last post by Rhuan on May 24, 2017, 03:28:49 pm »
Yes, that's what I meant because doing
Code: Javascript
  1. while(someCondition)
  2.     (new Sound("file.ogg")).play();
  3.  
isn't very effective :P
Hence my sound queue...

Code: [Select]
function SoundEffect(filename)
{
  this.queue = [LoadSound(filename)];
  this.name = filename;
}

SoundEffect.prototype.play = function()
{
  if(this.queue[this.queue.length-1].isPlaying()==false)
  {
    this.queue.unshift(this.queue.pop());
    this.queue[0].stop();
  }
  else
  {
    this.queue.unshift(LoadSound(this.name));
  }
  this.queue[0].play();
}
4
Engine Development / Re: miniSphere 4.5.11
« Last post by Eggbert on May 24, 2017, 03:15:57 pm »
Yes, that's what I meant because doing
Code: Javascript
  1. while(someCondition)
  2.     (new Sound("file.ogg")).play();
  3.  
isn't very effective :P
5
Engine Development / Re: miniSphere 4.5.11
« Last post by Fat Cerberus on May 24, 2017, 01:18:47 pm »
If by polyphony you mean playing the same sound multiple times simultaneously, then yes.  This feature is honestly long overdue and I don't know why I didn't implement it before.
6
Engine Development / Re: miniSphere 4.5.11
« Last post by Eggbert on May 24, 2017, 11:59:44 am »
Does this address the issue I brought up about polyphony?
7
Sphere General / Re: What is SFXR?
« Last post by Eggbert on May 24, 2017, 11:57:20 am »
I was looking at that as well. It would bw nice to see some of its required functions implemented in miniSphere.
8
Sphere General / Re: What is SFXR?
« Last post by DaVince on May 24, 2017, 07:01:16 am »
What Rhuan said - basically, a sound generator. I never use it myself because the sounds that come out of it tend to be very similar and overused in indie games.
9
Engine Development / Re: miniSphere 4.5.11
« Last post by Fat Cerberus on May 24, 2017, 02:33:48 am »
I'm doing some prototyping for the new Sample API, it's not ready for primetime yet (memory leaks galore!) but so far I can do this:

Code: Javascript
  1. let sample = new Sample('sounds/munch.wav');
  2. while (Sphere.run()) {
  3.         key = Keyboard.Default.getKey();
  4.         if (key == Key.Space)
  5.                 sample.play(Mixer.Default);
  6. }
  7.  

new Sample(...) loads the sound into memory, avoiding the overhead and latency of streaming.  And each sample.play() plays a new instance of the sound.
10
Programming / Re: What to do when you feel like you've made a monster?
« Last post by Radnen on May 23, 2017, 11:23:26 pm »
I modularize everything as much as I can. A separate file for healthbars, stats, attacks, etc.

At the end of the day, battle systems are going to be huge, there's not a lot you can do to minimize that. However, with the right mix of modules, many complicated bits can be made less confusing. At the end of the day, it's all about the cyclomatic complexity. Generally, the "flatter" your code, the better (usage of less nested scopes).
Pages: [1] 2 3 ... 10