MyApp --> Snake

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MyApp --> Snake

GabrieleCalarota
What do you think of my "Snake Game" classic version written in Jack code??

Please, report me any bug or any suggestion that you have, in order to help me and let my app be as great as possible!!!!

MySnake.zip

(Run on VMEmulator)

Thank you,
Gabriele
Reply | Threaded
Open this post in threaded view
|

Re: MyApp --> Snake

cadet1620
Administrator
Thanks for sharing your game.

Since the Jack language specifies that the order of evaluation is undefined, I added warnings about missing ()s in expressions. There are two source lines that are flagged.
    [c:/TECS/projects/student/09/Gabriele/Snake]
    % hjc .
    Processing directory .
    Processing .\Food.jack
    .\Food.jack(51):  if (((x>(511-5-big)))|((y>(256-5-big)))) {let x = 30; let y = 30;}
                                    ^                 ^
         Warning: undefined precedence "-" followed by "-".
         Warning: undefined precedence "-" followed by "-".
    Processing .\Main.jack
    Processing .\Snake.jack

    .\Snake.jack(156):  if ((y1[c]=y1[i]&(y2[c]=y2[i]))&((x1[c]=x1[i])&(x2[c]=x2[i]))) {
                                        ^
         Warning: undefined precedence "=" followed by "&".
    Processing .\SnakeGame.jack
For example, the (511-5-big) may be evaluated by different Jack compilers as
    (511-5)-big
as expected or as
    511-(5-big)
which would be a disaster!

I like to format complicated tests like these with some spaces to make the grouping more obvious
    if ( ((y1[c]=y1[i]) & (y2[c]=y2[i])) & ( (x1[c]=x1[i]) & (x2[c]=x2[i]) ) ) {


When I was playing the game on my system, I found it nearly impossible to hit the arrow keys at the right time to get to the target unless I slowed the execution speed way down. You might want to increase the hit detect to include the 8 white pixels surrounding the food.


If you want to place the food randomly, you might want to look at this random number generator.

You can start with a different random food location by seeding the random number generator.  Put up a splash screen -- as simple as something like the message "Snake game -- hit any key...". While waiting for the key press, keep incrementing a counter. Use this counter as the argument to LCGRandom.setSeed().

--Mark