Advertisement

Game event problem

Started by September 25, 2013 02:48 PM
1 comment, last by akssus 11 years, 4 months ago

Hello, I am very very beginner and I want implement a game event driving system in my game.

ex)

gameloop

{

if(whichEventHappen = checkHasReachedPoint)

{

if(whichEventHappen != null)

changeGameState(EVENT_RUNNING,whichEventHappen)

}

//in the EVENT_RUNNING state, execute script in the list 'whichEventHappen' one by one. after all is done return to play state

But I found some problems.

1. I'm not sure swapping whole game state is good or bad :-( ( I learned by myself )

2. if I use a script like

MOVE hero RIGHT 100

I want it to move right direction for 100, but how can I distinguish the hero in the object list which contains many other objects?

If I want one of 3 goblins to move right, I have no idea how to pick just one of them.

I need help. I read http://www.gamedev.net/page/resources/_/technical/game-programming/game-programming-genesis-part-vii-developing-r1294 this article's 'Effect" part. It is similiar to what I want to know.

Is there any tutorials for this?

p.s sorry for my poor English.

The code is confusing: Unless checkHasReachedPoint can be null at some point, then there's no reason to check whichEventHappen, because it's basically guaranteed not to be. Also, it's a list? You'll have to explain that, and the reasoning behind it, in a little more detail.

As for the switch: It should be virtually free, in terms of performance, because you're simply switching code paths. I mean, it could be something no more complex than swapping a function pointer.

For things like selection and movement: There should be no need to "search" for the hero. The code that runs actions for that object should hold a pointer/reference to it, and manipulate the date in that way.

RTS selection scenarios require a "picking" setup, but that should just fall out of your collision system, where you can draw a "box" around a portion of the world, and get a list of all objects within it.

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+
Advertisement

sorry, my explanation was incomplete.

I make a 2D platformer game. And if player reached a specific area, event is triggered.(Cutscene? I'm not sure using which word is right)

Then characters should play animations, move to somewhere, camera works, etc.

The problem is,

IF
True()
THEN
RESPONSE#100
CutSceneID(Player1)
ActionOverride("TROLL",Kill(Myself)) // See Note #7
EndCutSceneMode()
END

In this script(found in google), player1 want "TROLL" to die. may be there are some others like MoveTo("TROLL").

But I don't know how to specify "TROLL".

If there are many TROLLs and I want only one to die, I don't know how to deal with it.

Firstly I thought, give IDs to every objects in the map. player1.id = 0, troll1.id = 1, troll2.id = 2 ... It may works if there are only limited number of objects(in map1 file).

But when some objects are artificially added by summoning creature or something and I want make one of those move by scripts, there are no way to identify just him.

So thought again, then how about just do sequential search and find out specific class. Do for loop and find troll class and move him if it was found. But this method will find out too many troll class. I only want one of those.

Maybe I am fundamentally wrong. Anyway I need a certain solution for this. I can't sleep at night because of this :-)

This topic is closed to new replies.

Advertisement