Jump to content
Sign in to follow this  
catsfolly

Colored Squares Snake Game (WIP?)

Recommended Posts

Since GroovyBee recently wrote and posted a Coloured Square plotting routine for IntyBasic, I thought I would use it to try and make a colored squares version of my snake game.

 

The original Snake game tried to fit in 10 lines, but this game is over 300 lines long.

 

It looks like this:

 

post-14916-0-39203900-1454001177_thumb.gif <- click to animate

 

Here is the rom if you want to give it a try:

 

cs_snake.rom

 

and the source if you are the kind of person who likes to read source code:

 

cs_snake.bas

 

Have fun! Send comments!

 

Catsfolly

 

P.S. I just "finished" it, so there could be bugs...

 

P.S.S. In the jzintv emulator, the sprite and the snake seem to move together, in the gif file they look out of sync.

  • Like 9

Share this post


Link to post
Share on other sites

The original Snake game tried to fit in 10 lines, but this game is over 300 lines long.

 

 

So, having done it both ways, was there an actual advantage to the new library-based version? I mean, what did those 300 lines buy you?

 

-dZ.

Share this post


Link to post
Share on other sites

That's really cool! I tried to use Colored Squares mode to make the building in the background in Mad Bomber. It was really hard for me to set up the cards so I ditched the idea and went with the remaining GRAM cards available for the background.

Share this post


Link to post
Share on other sites

 

So, having done it both ways, was there an actual advantage to the new library-based version? I mean, what did those 300 lines buy you?

 

-dZ.

Readability! Writing a game in 10 lines is an interesting trick, but the resulting code - with many statements on one line, no comments, short variable names, etc - is pretty unreadable.

  • Like 2

Share this post


Link to post
Share on other sites

Well, for an extra 290 lines, you can make one think there's a whale harpooning level included. :P

  • Like 1

Share this post


Link to post
Share on other sites

Variation 1:

 

Mirror Snake!

 

post-14916-0-29333500-1454991098_thumb.png

 

This is a variation of the colored square snake game. In this version you control two snakes - one snake moves as a mirror image of the other.

Each snake is in its own 2d space. The food randomly appears in one of the spaces.

 

Here is a (ridiculously long) gameplay gif:

 

post-14916-0-48792900-1454991101_thumb.gif <- click to animate.

 

Here is the rom file:

m_snake.rom

 

And the source:

m_snake.bas

 

Since the snakes can end up with different lengths, I faced the problem of what to do when one snake runs into itself and dies, while the other snake (being shorter) doesn't die.

 

The current solution is this - when one snake dies it goes into "erase mode" where it erases all its segments. If both snakes go into erase mode, the game is over. If one snake finishes erasing all of its segments and the other snake is still alive, then the dead snake is revived as a 2 segment snake, and the game continues. If you can keep one snake alive, you can play forever!

 

Comments, suggestions?

 

Catsfolly

 

P.S. Blooper reel dept.

 

I created this game by taking the colored squares snake game and changing all the snake variables to arrays. The first time I compiled and ran the program, it looked like this:

 

post-14916-0-69209900-1454991103_thumb.gif <- click to animate.

 

 

Edit. Here is a new faster smoother, less buggy version based on DZ-Jay's comments:

Edit2 - fixed a few bugs and added a start delay...

 

rom:

m_snake.rom

 

source:

m_snake.bas

 

 

Edited by catsfolly
  • Like 6

Share this post


Link to post
Share on other sites

Interesting. Does it automatically control the snake on the side in which the food is? Oh, I see that you always control the left one, that makes it harder.

 

OK, I played it for a little bit and here's some feedback. It was produced in a sort of "live streaming," so just read throughout:

  • Damn! Whenever the food is on the other side, it is hard to adjust my brain to move the mirror image. After a couple of tries I kind of trained my brain for it, but it was still hard. I'm not sure if this sort of difficulty is good or bad, but it is challenging.
  • There should be a slight pause after drawing the play-field, and before starting to move the snakes. It feels rushed as it is.
  • The game should allow to restart after it ends.

<...plays more...>

  • I didn't see the "erase mode" at all; whenever one snake runs into itself, it dies and the game is over.
  • My snake is able to commit suicide by smashing its head against into its neck when I move backwards. I'm not sure if backing up should be allowed.

<...plays more...>

<...plays more...>

<...plays more...>

<...plays more...>

  • I experienced what looks to be "erase mode," but I don't know how it occurred. It looked like I was "backing up" and smashing my snake against itself (like I've done so many times before), but this time the snake started eating its tail end... (?) It didn't end the game, though; when it finished, the snake appeared at a random place and continued moving.

<...plays more...>

  • Given that eating food on the mirror image is harder, should its scoring increase?
  • So far, the only challenge I experience is the tricky and apparently random switch from "normal" snake to "mirror" snake when the food appears on the other side. I think it's a fine challenge (I'm growing to like it), but I can see it getting boring over time. I'm afraid that the "mirror" bit may seem more of a gimmick than an actual game-play mechanic.

<...plays more...>

  • Hmmm... I was able to reproduce the "erase mode" now, but my snake re-incarnated in a wall!!! :o instant death!

<...plays more...>

  • I reproduced "erase mode" now (I'm getting a bit better at this schtick), and for some reason, I was not able to commit suicide after it.

<...plays more...>

<...plays more...>

<...plays more...>

  • OK, I played a few more times and I can see that what I was calling "backing up" or "suicide" before is nothing of the sort: it was just me slamming the snake against its side on a very quick but bad turn. This causes the snake to enter "erase mode" but dies in place. This is why it appeared as if it was backing up, because it doesn't eat itself, it just rams its head against its neck, but from the side.

<...plays more...>

<...plays more...>

  • Hmmm... It is definitely "suicide"! I can't seem to reproduce it faithfully, so it may be stochastic. I think it may be a race condition with the controller handler. Here's how I remember it when it happens: I am moving, say, upwards and I press "Left," and immediately followed by "Down"; the snake doesn't zig-zag because I changed directions between the frames that it takes to effect it. The end result is that the snake head turns around into itself, appearing to have rammed into its neck, but it dies and the game is over.

<...plays more...>

  • For it to happen, the snake must have eaten food at least once.

<...plays more...>

  • Nope, it happens the same at the very beginning, before eating any food.

<...plays more...>

<...plays more...>

<...plays more...>

<...plays more...>

  • OK, I have confirmed the instructions to reproduce from above: Go in one direction and switch to one side and immediately to the opposite of the original direction. For instance: going up, press left or right, and immediately down.

<...plays more...>

  • The same works in when originally going Up or Down.

<...plays more...>

  • And confirmed for sideways also.

<...plays more...>

<...plays more...>

  • Yup. Smells like a bug to me. ;)

 

That's it for now. I hope this blathering proves useful. :)

 

-dZ.

  • Like 2

Share this post


Link to post
Share on other sites

I have one more bit of feedback: I wish the movement were more smooth. I know you are using Colored Squares mode, but it seems like the MOB "head" of the snake moves in sharp steps too rather than giving the appearance of smooth movement.

  • Like 1

Share this post


Link to post
Share on other sites

I have one more bit of feedback: I wish the movement were more smooth. I know you are using Colored Squares mode, but it seems like the MOB "head" of the snake moves in sharp steps too rather than giving the appearance of smooth movement.

Thanks for trying my game and all of your comments!

 

I think fixed the bug where the snake could do a 180 and run into itself. Give it a try when you get a chance (I put the new version at the end of the original Mirror Snake post).

 

I put an additional snake colored sprite behind the head, and tried to move both sprites smoothly in the new direction. This makes the head smoother, although the tail is still not smooth...

 

Thanks again,

 

Catsfolly

 

P.S. Here is a new gif:

 

post-14916-0-62364500-1455033385_thumb.gif <- click to animate

 

At game over you can restart the game by hitting any key on the keypad.

 

My first upload had some bugs, so I fixed them and added a start delay.

Edited by catsfolly

Share this post


Link to post
Share on other sites

I'll try it tonight. A few comments on your last post:

 

1) looks a lot better, but the jerkiness of the tail is a bit distracting.

2) Perhaps you can add one MIB to the tail end to smooth it's movement.

3) I recommend adding support for the disc on Game Over to restart, as well. It's a rather common usability pattern. :)

 

dZ.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...