Main forum > Beta Tests

basic snake game

(1/3) > >>

tokke:
Just starting with glbasic. made a little snake game. all placeholders graphics
http://dl.dropbox.com/u/28111609/snake.rar

I set the speed(dificulty) by changing the fps. any other way?

EDTI: O and i can't seem to work with sprcoll. It feels like it makes a box and i collide with it, even when there is no sprite to collide with. I managed to make it work. But horrible code.

Kitty Hello:
Use boxcoll or maybe use a grid for the background and snake and test whats in the grid.
Hello, btw. :)

erico:
Great!

Add enemies/boss, WASD control + mouse shooter on an arena style, put some make up on gfx and you have a winner! :good:

I noticed the blocks move per/block on a grid, not a pixel movement, on higher level it looks like skipping frames, on lower level it looks ok as a style.

Better not use the FPS as it will speed up/low everything.
You can control the speed of the snake with variables, similar to how the PONG example goes when moving the ball or bats.

As for collision, Kitty´s idea of a grid, should I understood this right, seems like a great solution for me.
Like having a dim variable on 2 dimensions and use those coordinates to  check collisions.

Welcome.

tokke:
I just started with this and plan on expanding.

Some stuff already on paper (not code) now just need to "find" the code.

Some things are just not clear for me.

I'll just try to explain:
-The "head" of the snake is 10x10 pixels. So i move 10 pixels in all directions. So how do I control the speed wihtout limiting fps? (where can i find the pong example?).
-So instead of using sprcoll for the walls, i just make a 2 DIM array, and assign booleans like wall[0][0]=1 would be a wall on pixel 0,0 and i can test if the coords. of the snake head are within those boundries? That is what you were saying?
-You talk about mouse shooter. Any code example for mouse shooting? I know what has to be done? But can't seem to find the code for it. my problem: Player location = x,y and mouse location = x2,y2. How do I let my "bullet" travel in a straight line from x,y to x2,y2 and go past it? that is the code i can not find.

And as i said, images are just place holders :)

O and sorry for the worst english ever. Native dutch speaking

kanonet:

--- Quote ----The "head" of the snake is 10x10 pixels. So i move 10 pixels in all directions. So how do I control the speed wihtout limiting fps? (where can i find the pong example?).
--- End quote ---
Simple: dont move 10 pixels each frame, move 1-3 for slower and up to 10 for faster. Just try to play with this a bit.

--- Quote ----So instead of using sprcoll for the walls, i just make a 2 DIM array, and assign booleans like wall[0][0]=1 would be a wall on pixel 0,0 and i can test if the coords. of the snake head are within those boundries? That is what you were saying?
--- End quote ---
Exactly.

--- Quote ----You talk about mouse shooter. Any code example for mouse shooting? I know what has to be done? But can't seem to find the code for it. my problem: Player location = x,y and mouse location = x2,y2. How do I let my "bullet" travel in a straight line from x,y to x2,y2 and go past it? that is the code i can not find.
--- End quote ---
Wait bullet? In snake? Darn i didnt play this game for many Years.^^ But in general its like this:

--- Code: ---fire shot:
bulletx=x
bullety=y
x2=mouseposition
y2=mouseposition
each frame move bullet:
inc bulletx, sgn(x2-bulletx)
inc bullety, sgn(y2-bullety)
check if youre at your target:
if bulletx=x2 and bullety=y2 or hit_something_in_world() then BOOOOM()
--- End code ---
This is just pseudo code of a general idea how you do things like this, but maybe it helps you. Of cause it can get improved very much, e.g. for better looking bullet fly etc..

Navigation

[0] Message Index

[#] Next page

Go to full version