A Snake Fork

Advice on general approaches or feasibility and discussions about game design

A Snake Fork

Postby Tiash » Sun Jul 20, 2014 5:15 pm

Last week, i have fork Snake by Ripper121 for do a version that uses a list instead an array, for find a more efficient version of the same game.

But i have a bug: when the snake hits a food, it stops running.
I think that problem is in the function "next_step()" after it's test "hitFood()"
Code: Select all
void next_step() {
  //Controllo se mangia
  if (hitFood()) {
    insertBody();
    score = score + point;
    nextFood();
  } else {
    insertBody();
    removeBody();
  }
}

I do not understand what causes the problem.

Can anyone help me?
How can i debug it?

Here the code
User avatar
Tiash
 
Posts: 18
Joined: Sat Jul 12, 2014 7:28 am
Location: Italy

Re: A Snake Fork

Postby Tiash » Sun Jul 20, 2014 7:35 pm

I have find the problem!
I was wrong to implement the function "removeBody" :lol:
I have find a inefficiency too, that in the next days i will fix :D
The code is now update! (and working too)
User avatar
Tiash
 
Posts: 18
Joined: Sat Jul 12, 2014 7:28 am
Location: Italy

Re: A Snake Fork

Postby ripper121 » Sun Jul 20, 2014 8:23 pm

Nice to see first mods ;)
User avatar
ripper121
 
Posts: 224
Joined: Fri Apr 04, 2014 2:02 pm
Location: Germany

Re: A Snake Fork

Postby Tiash » Mon Jul 21, 2014 11:18 am

I have update the code with some little fix.

Image

ripper121 wrote:Nice to see first mods ;)

:D
User avatar
Tiash
 
Posts: 18
Joined: Sat Jul 12, 2014 7:28 am
Location: Italy

Re: A Snake Fork

Postby ripper121 » Mon Jul 21, 2014 12:37 pm

What are this crosses?
If you like you can Post the game in the Snake thread or i can include it in the Main post as a Mod.
User avatar
ripper121
 
Posts: 224
Joined: Fri Apr 04, 2014 2:02 pm
Location: Germany

Re: A Snake Fork

Postby Tiash » Mon Jul 21, 2014 12:42 pm

ripper121 wrote:What are this crosses?

The crosses indicate where the snake has eaten something. :D

ripper121 wrote:If you like you can Post the game in the Snake thread or i can include it in the Main post as a Mod.

First i want to implement some ideas. When I am satisfied, I will add :D
User avatar
Tiash
 
Posts: 18
Joined: Sat Jul 12, 2014 7:28 am
Location: Italy

Re: A Snake Fork

Postby ripper121 » Mon Jul 21, 2014 1:51 pm

snake[1].jpg
snake[1].jpg (64.3 KiB) Viewed 5315 times

This is a screenshot from the Nokia Snake 2, you can see the bigger part which is your cross.
It would be nice to see such graphics :D
User avatar
ripper121
 
Posts: 224
Joined: Fri Apr 04, 2014 2:02 pm
Location: Germany

Re: A Snake Fork

Postby rodot » Mon Jul 21, 2014 3:22 pm

This topic reminds me of a snake game I made on a very, very early prototype of the Gamebuino :lol:

User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France


Return to Project Guidance & Game development

Who is online

Users browsing this forum: No registered users and 117 guests

cron