0 registered members (),
1,382
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: REQ: 2D snake type game ?
[Re: dracula]
#257244
03/21/09 21:49
03/21/09 21:49
|
Joined: Jan 2004
Posts: 2,062 Hamburg, Germany
slacer
Expert
|
Expert
Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
|
Hi,
I don't have such a script for you, but some suggestions how you could do it.
- create a large room with some wall fragments inside this level. - add some entities with a simple action and enable the needed events. - you need a player entity. Mark it as player by setting an entity flag to ON - put a camera above the level in WED (add->position) and turn it downwards. Play a bit with its z-value until the camera can see the whole level.
- add some keyboard control to your program in order to turn your player to the left or right side. Your action needs the code to always run into current direction.
If you detect a collision with an entity, you check the "you.flag1" to see, if it was your tail - and maybe you let the snake die in this case.
If it is a wall, the snake has to die, too.
If it was something to eat, you increase a grow skill in your player entity.
---------------------- This was the main part.
---------------------- How does a snake work? - create an array of structs to hold x- and y- positions, or create two arrays if you dislike structs.
Initialize the array with the inital length of your snake (depends on the game level) write xy positions into your array. if your snake moves one step forward and it does not grow, you copy the position values from the last-1 element into the last element and you do this for all elements. move your head one step forward and write its new position into the array element with the highest index. Now let all tail segment read its position from the array and move it to its new position.
If you are in groth mode, you simply fill an additional array element and don't change a single position of the tail.
This should get you started.
-- slacer
|
|
|
Re: REQ: 2D snake type game ?
[Re: dracula]
#257329
03/22/09 17:40
03/22/09 17:40
|
Joined: Jan 2004
Posts: 2,062 Hamburg, Germany
slacer
Expert
|
Expert
Joined: Jan 2004
Posts: 2,062
Hamburg, Germany
|
Hi dracula, I would not use panels because they would not create the collisions with walls. Use a simple sphere as body. In fact, this game would be a 3D game seen from above (like a bird looking down). Because the camera is so high, that it can see the whole level, it looks like a 2D game. Try to make your game without the snake (only the head) and let it eat all things in the area. Once you get this done, I can help you if you don't understand to use my previos post. -- slacer
|
|
|
Re: REQ: 2D snake type game ?
[Re: slacer]
#257335
03/22/09 18:36
03/22/09 18:36
|
Joined: Apr 2008
Posts: 437
dracula
OP
Senior Member
|
OP
Senior Member
Joined: Apr 2008
Posts: 437
|
BTW: If you wanted it to be truly 2D, how might you do it ?
Thanks
Last edited by dracula; 03/22/09 18:37.
|
|
|
|