2 Replies - 227 Views - Last Post: 26 October 2010 - 10:19 AM Rate Topic: -----

#1 giuseppe105  Icon User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 438
  • Joined: 15-May 08

custom events loaded from a file

Posted 25 October 2010 - 01:23 PM

I am making a game engine. and i need to be able to have the program that makes the maps for the engine be able to add events that will occur in the game when run though the engine.

I have no idea what so ever how to accomplish this.

If anyone out there dreaming in code has an idea how to. please share your thoughts.

i am not asking for code. i am asking for logic.

This post has been edited by giuseppe105: 25 October 2010 - 01:23 PM

Is This A Good Question/Topic? 0
  • +

Replies To: custom events loaded from a file

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10175
  • View blog
  • Posts: 37,571
  • Joined: 27-December 08

Re: custom events loaded from a file

Posted 25 October 2010 - 02:51 PM

Polymorphism is probably the way to go here. Basically, you can define a GameEvent super class which accepts some parameter, possibly a Sprite, and does something to that Sprite through a standard (or even abstract) act() method. To customize act(), you could use inheritance.

Now if your Map is Tile-based for example, your Tile class will probably just store a GameEvent and a Sprite. So when the Sprite is set (meaning you have a new Sprite that has stepped onto the Tile), that would trigger the GameEvent to act() on the Sprite.

Now of course your Map doesn't have to be Tile-based, and the same logic applies for cutscene-type events or other milestones in the game. But that is a good starting point logic-wise.
Was This Post Helpful? 1
  • +
  • -

#3 giuseppe105  Icon User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 438
  • Joined: 15-May 08

Re: custom events loaded from a file

Posted 26 October 2010 - 10:19 AM

thank you for the reply. sorry im so late to answer.

i don't really understand what you mean. but i was thinking of making my map maker save a flag to a file and the parameters to the method the engien should run

so in the file it would look like

1 stands for the first method. this method is a teleporting event to change maps.

1 map1 xloc1 yloc1 xloc2 yloc2// teleport event
2 "Citizen: What a lovely day we are haveing." xloc yloc// message event
3 walk 32 32 96 96 xloc yloc// walk event to move player or npc


the only problem is i know how to call a variable from a label with a hashmap. but i have no idea how to call a method from a label.

This post has been edited by giuseppe105: 26 October 2010 - 10:23 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1