UzeSnake game - Understanding the 'under the hood mechanics'

Use this forum to share and discuss Uzebox games and demos.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by Artcfox »

I have never used AVR studio, and I don't use Windows, so I am not sure.

There are instructions and a download for the command line toolchain for all OSes (including Windows) here:

https://www.microchip.com/en-us/tools-r ... -compilers#

From what I understand there is nothing to install, you just extract it to a directory, and then set a PATH in a command prompt and it should work. There is both the download and a release notes for the 8-bit toolchain that explains how to use it.

If you are willing to boot a Linux Live image from USB, or run a VM I walk through creating a Hello World app from scratch: https://youtu.be/SRUv9T9vyQ4

My first video walks you through getting a Live Linux USB downloaded and booted: https://youtu.be/vT2TUSZWDf8
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by mapes »

I got a mode 3 version working now outputting video. I used Paul's Space Invaders as a starting point and it's working good.

Hopefully I'll have a mode 3 version of Snakes out in a month using the snake graphics.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by uze6666 »

Very cool thread, I have yet to try tour game. Your experience at the fair remember me when I went to Maker Faire in NY. Kids were there non stop. Some of the favorites were donkey Kong, Pac-Man and...Tron because I think it was the year Tron Legacy came out!

Avr Studio 4 is very old and not supported anymore. Have you tried Microchip Studio (Formely Atmel Studio 7). IIRC it can import and convert APS projects. It's based on VisualStudio so it has much more bells and whistles.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by mapes »

Making progress. I rewrote majority of the variables into a 'snake' struct which required alot of code revision changes. I also changed from a 2 dimension 'char' grid used to track the snakes location for collision detection to the 'GetTile' function.

Interesting thing about the GetTile() function listed in the API, when I tried to call it using the SpaceInvaders code as a base, it wasn't in uzebox core code. I had to look at other demos and found the functions coded in the game LodeRunner.

I'm still trying to figure out how to get mode 3 working to work using the various "print" functions using the fonts.

I'll take a look at how Donkey Kong did it next.

I also have an 'artifact' for tile 0,0 that shows up at startup, and remains throughout the game. Note sure why...

Using mode 3, I'd like to get the snakes head and tail to 'slide' using sprites down the road. But first, the fonts!

I've attached where I am at now. Artcfox's snake graphics make the game look really good with the snake moving around. 1 player game 'works' and you grow eating apples, but don't expect to keep score since the print statement is busted. The game doesn't start until you press start. The mess all over the screen is me using print statements...

If you try a 2 player game(1 player select), you'll see that I haven't set all of the snake graphics for player 2 yet.
snake_Mode3.hex
(92.2 KiB) Downloaded 60 times
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by Artcfox »

It looks good!

I don't think you will have enough sprite to pull of smooth movement for the entire length of the snake, so what I would do instead is create more tiles with it in different phases of movement, and then the entire length of the snake can look like it is sliding. Then you could use the extra RAM tiles for RAM fonts, which would let you dynamically set the foreground and background color, or even animate the colors, and they won't waste tiles or take up much space at all. Take a look at my Circuit Puzzle source code for examples of the RAM fonts, I use them for displaying the help text, and for the info bar text in the game: https://github.com/artcfox/circuit
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by mapes »

Sorry, when I meant snake sliding, I meant only the head and tail tiles would slide over the body segments. The segments would just appear under the head tile as it moves out to the next tile and the tail tiles would slide over the last segment. If I wanted to get fancy, I'd try to have multiple frames show the tail piece turning with the segment.

It may look really bad though with the crisscross pattern in the snake not moving appropriately...

Otherwise after getting text working, the next part would be to add levels with layouts and maybe some enemy snakes or moles that go up and down. Just thinking of some easy things to do. Kinda finish out a game...
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by mapes »

Making decent progress on the snake game in my 'down' time from regular responsibilities.
snake_mode3_v2.hex
(99.14 KiB) Downloaded 67 times
Currently it is 1 player, the 2nd player is the AI snake. - If you try to do 2 player, the AI snake moves at double speed and tries to get the P2 input as well.

The AI snake is relatively rudimentary, but it does basic collision aversion and seeks the apple. It doesn't think far enough to avoid some obvious dead end kills.

I also put a 'mole' that pops up and down on a timer. Each mole 'enemy' is its own struct, so it can have its starting position set, as well as the time delay between going up and down.

I also implemented in the code for the apple to be able to 'move around', but I don't have it moving yet in this uploaded version.

Next up for coding is the 'snake explosions' when snakes die. Shouldn't be too hard, but may take some time to implement. But I added the graphics already Dr. Mario virus explosion style.

I was thinking of doing levels, which could still work out well, but I could also just add new moles that pop up on the map as time progresses to add some extra 'squeeze' to the map.
User avatar
D3thAdd3r
Posts: 3222
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by D3thAdd3r »

2 player and different obstacles will be a cool unique spin on the old classic. Looking forward to seeing how it comes together as a new gameplay dimension.
User avatar
mapes
Posts: 174
Joined: Sun Feb 13, 2011 7:04 am
Location: Seattle

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by mapes »

I present Snakes version 3.
snake_mode3_v3.hex
(105.2 KiB) Downloaded 60 times
Now featuring:
5 Levels
2 player mode (with enemy snakes)
4 lives
and of course, various bugs that need to be cleaned up and fixed.

The starting speed of the snake is fast, but using the A,B,X,Y buttons you can control the speed now.

After a player eats 10 apples, the exit opens. Once a player snake reaches the exit, it changes to the next level. When you die, you restart the level.

Different level apples can cause the snake to grow different amounts. (adds a dynamic to certain levels)

When you get to level 4, you run into the first enemy snake, and it moves starting speed fast. But once you kill an enemy snake, its gone.

Todo list:
An intro screen...
More levels...
Blue apples (for the blue snakes)
a count down timer if you take too long.
User avatar
D3thAdd3r
Posts: 3222
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: UzeSnake game - Understanding the 'under the hood mechanics'

Post by D3thAdd3r »

This gets really tough! I still haven't managed to get to the enemy snakes, but I'll take another stab at it later.
Post Reply