Turn-based Battles Flashcards

1
Q

Controlling Game State (Manager)

A
-init
   |
  V
-startTurn
-wait
-process
-checkFinish -> win (ai = 0)
                      -> lose (player = 0)
                      -> End Turn
                                 |
                                V
               Loop back to startTurn
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Initialize

A

-clean up data
-spawn characters
-set up UI |
V
global.units

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

obj_manager

A

(create event)

//Setting Up Combat Phase Constants
enum phase
{
	init,
	startTurn,
	wait,
	process,
	checkFinish,
	endTurn,
	win,
	lose
}

combatPhase = phase.init;

//Create List

global. units = ds_list_create();
- –

(clean up event)

if (ds_exists(global.units, ds_type_list))
{
ds_list_destroy(global.units);
}

(step event)

//Cycling Through Combat Phases
switch(combatPhase)
{
	case phase.init:
		for(var i = 0; i < instance_number(obj_spawner); 
                i++)
		{
			var spawner = instance_find(obj_spawner, 
                        i);
			var  unit = 
                        instance_create_depth(spawner.x, 
                        spawner.y, 0, obj_pUnit);
			ds_list_add(global.units, unit);
		}
		combatPhase = phase.startTurn;
	break;
case phase.startTurn:
	combatPhase = phase.wait;
break;

case phase.wait:
	combatPhase = phase.process;
break;

case phase.process:
	combatPhase = phase.checkFinish;
break;
	case phase.checkFinish:
		if (keyboard_check_released(vk_space))
		combatPhase = phase.endTurn;
		if (keyboard_check_released(vk_enter))
		combatPhase = phase.win;
		if (keyboard_check_released(vk_control))
		combatPhase = phase.lose;
	break;
case phase.endTurn:
	combatPhase = phase.startTurn;
break;
	case phase.win:
		//fill
	break;
	case phase.lose:
		//fill
	break;
}

(draw GUI event)

draw_text(0, 0, string(combatPhase));

for (var i = 0; i < ds_list_size(global.units); i++)
{
	draw_text(0, 16+(i*16), string(global.units[|i]));
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

obj_manager explained

A

for(var i = 0; i < instance_number(obj_spawner);
i++)
{
var spawner = instance_find(obj_spawner,
i);
var unit =
instance_create_depth(spawner.x,
spawner.y, 0, obj_pUnit);
ds_list_add(global.units, unit);
}

  • will loop “var spawner = instance_find(obj_spawner, i);” until the number of instances of obj_spawner is hit
  • “var i = 0” initializes the variable, “i < instance_number(obj_spawner); “ checks if there is less than the desired number of enemies and if true applies “i++”, which adds one increment and then loops the process again untul “i < … “ is flase
for (var i = 0; i < ds_list_size(global.units); i++)
{
	draw_text(0, 16+(i*16), string(global.units[|i]));
}

*will loop for as many units as are in the ds_list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly