10.03.2019 - Round 1 results of our "A Love Letter For FreeBASIC" game dev competition have been published. Please be sure to check the results thread: http://games.freebasic.net/forum/index.php?topic=629.0. Don't forget that the competition is continuing with a round 2, lasting till 29th of April, 300 USD first prize. Stay tuned!

Author Topic: Snake  (Read 5634 times)

hd_

  • Recruit
  • **
  • Posts: 35
    • View Profile
Snake
« on: February 25, 2008, 05:56:19 AM »
Simple snake game:

Features (exaggerated):
-Super elite modern cell shading techniques!
-Fast paced action!
-Multiplayer action extends the fun for everyone!
-All new complexicated obstacles!
-Bonus foods!

Screenshot:
new:


old:


My Top score:
All previous top scores are invalid.

Download:
Snake 0.2.1 [NEW]
Snake 0.2
...old...

What's new:
-Source code cleaned up.
+Multiplayer (single computer).
 -Can be set so that snakes die when the collide.
 -Can be set so that snakes die when they collide into dead snakes.
 -When multiple snakes collide at the same time, and snake_snake_collision is true, then they both die.
 -When multiple snakes reach an item at the same time, they both receive the same points for it.
-bonus items.
-obstacles.
-The bug which caused keys to sometimes not get detected is now fixed.

Future plans:
-computer opponents.
-graphics updates
-menus
-obstacle editor which also allows you to set up where the next food should spawn, and where and when the next bonus should spawn. (sort of like a mission editor or something)

Distant future plans:
-network multiplayer

Other Notes:
Quote
-SDL_GL_SetAttribute(16,1): 16 is the code for SDL_GL_SWAPCONTROL, not a part of the SDL headers supplied with FB (they are old). SDL_GL_SWAPCONTROL sets vsync.
-Adding SDL_Delay() to the time wasting while loop stops your program from hogging resources.
-The examples demonstrating SDL+GL+FB show the use of SDL_DOUBLEBUF flag- however SDL tuts suggest NOT to use this, and to SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1)
« Last Edit: February 25, 2008, 05:17:24 PM by hd_ »

nkk_kan

  • Forum Howler
  • ****
  • Posts: 193
  • Let's rocK~!
    • Yahoo Instant Messenger - nkk_kan
    • View Profile
    • nkk's code cache
    • Email
Re: Snake
« Reply #1 on: February 25, 2008, 07:13:39 AM »
excellent! two player adds life to the game! :P

one tiny thing...
Quote
-Can be set so that snakes die when the collide.
 -Can be set so that snakes die when they collide into dead snakes.
how do you set this?
also some more info in readme would help :P

hd_

  • Recruit
  • **
  • Posts: 35
    • View Profile
Re: Snake
« Reply #2 on: February 25, 2008, 03:54:48 PM »
You have to set it in the code, main.bas:
Code: [Select]
players.snake_snake_collision=0
players.dead_snake_collision=0

Set it to how you want.

Just so so you know, you can set it to single player or up to 8 players through the code as well, in main.bas. It's pretty simple, the arguments are:
Code: [Select]
players.addPlayer("NAME",RED,GREEN,BLUE,X,Y,DIRECTION)Direction is either SNAKE_UP, SNAKE_DOWN, SNAKE_LEFT, SNAKE_RIGHT.

Also, you can change the size of the play field by changing HCELLS and WCELLS (they are #defines).

I will try get menus into the next version :P


edit:
*Facepalm* - whoops, food can land on the obstacles :P I didn't test the obstacles too thoroughly last night (just whacked them in and shipped it :P). I upload the new version when I get a chance.
« Last Edit: February 25, 2008, 03:59:59 PM by hd_ »

Lachie Dazdarian

  • Double dipper
  • Administrator
  • Forum Sage
  • *****
  • Posts: 1305
    • Yahoo Instant Messenger - lachie13
    • View Profile
    • The Maker Of Stuff
    • Email
Re: Snake
« Reply #3 on: February 25, 2008, 04:50:39 PM »
Very nice work. Only, the white line with dark edges had a strange charm to it.

Any chance to code a computer opponent?

And yes, you really need menus if you are aiming to release a proper game. I also recommend you to compile some sort of challenge mode whose properties the player won't be able to change. Otherwise, you'll get a very customizable toy and not a game.

Also, did you try to experiment with the background, like making it shaded? You know, like the blue background in Adigun's Pixel Craft program. Don't know if it would work, but maybe you should do some tests just to see. Same thing with the snakes' body going more and more dark as it goes away from the head. Well, at least to some extent. Experiment!
"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist

hd_

  • Recruit
  • **
  • Posts: 35
    • View Profile
Re: Snake
« Reply #4 on: February 25, 2008, 05:10:19 PM »
I uploaded the fixed version.

Quote
Very nice work. Only, the white line with dark edges had a strange charm to it.
You are right, in 0.2.1 there are now 2 exes: '2playerSnake.exe' and '1playerSnake.exe'. 1 player snake has the screen size reduced and the colour set back to white ;) But of course in multiplayer, not everyone can be white- it's confusing enough as it is :P

Quote
Any chance to code a computer opponent?
Yes :) I was thinking it might be cool if I set up the framework for it, then others could have a go at writing their own ai. Then there could be a battle :P

Quote
And yes, you really need menus if you are aiming to release a proper game. I also recommend you to compile some sort of challenge mode whose properties the player won't be able to change. Otherwise, you'll get a very customizable toy and not a game.
I agree here as well, lots of tiny factors can change the number of points you can easily score, so a mode where nothing can be changed is necessary for top score tracking.

Quote
Also, did you try to experiment with the background, like making it shaded? You know, like the blue background in Adigun's Pixel Craft program. Don't know if it would work, but maybe you should do some tests just to see. Same thing with the snakes' body going more and more dark as it goes away from the head. Well, at least to some extent. Experiment!
I haven't yet :P I will see what I can come up with ;)