Advertisement

How can I create events ?

Started by February 20, 2002 05:44 PM
2 comments, last by Maduray 22 years, 9 months ago
HI, Do you know how I can create and event in my game. I mean, when my sprite ( the character ) is in front of object or something (chest,...) and push a button the chest open. Can you tell me how I can do this ? (with DirectX or something) Thanks Maduray ------** The power of the newbie is within you **------- -----** (^_^) **-----
-----** (^_^) **-----
when the user hits a key which is used for opening your chest you have to check if a chest is near the player if so, open it.
Advertisement
quote: Original post by Maduray
Can you tell me how I can do this ? (with DirectX or something)


DirectX is an I/O API, essentially. It doesn''t do game logic. In other words, you''re going to have to handle everything that relates to how your in-game objects interact. An example (in pseudocode):
if(KeyHit(RIGHT))    if(Tile[PlayerPos.X + 1].Passable == false)        switch(Tile[PlayerPos.X + 1].Type){           case T_CHEST:               Tile[PlayerPos.X + 1].Whatever() //have another switch-case to handle each tile (sprite)''s                                                 //responses to environmental action...               break           //and so on......


Hope that helps a little. It''s not very clear, but if you have any questions, just ask; I''ll keep an eye on this thread.

Later,
ZE.



//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

[twitter]warrenm[/twitter]

Thanks a lot! It is a great help. Tonight I''ll sleep with a mind wiser

Hmm. can you tell me how the position of the charater in this case can be determined ? Is it a Rect ?

Thanks
Maduray

------** Newbies rules ! **------
-----** (^_^) **-----

This topic is closed to new replies.

Advertisement