Snake revisit.
Snake revisit.
So it's been an interesting journey to this point. My new to me physical zx81 needs an adjustment to the composite video mod as it's currently showing both a grey rather than white screen and the text is distorted so I'm still on the emulator currently whilst I wait on a new composite video mod board.
After 40 years away I'm rediscovering sinclair basic but have also found mcoder2 which is a game changer albeit with it's idiosyncrasies around random number generation!
I never understood machine code as a kid and that is a project for later.
My initial project has been a snake style clone written in basic adapted for and then compiled with mcoder 2
This is week one.
Currently produces a game play area, moving snake, four direction control, both snake and walls have crash detection. Each move increase the score and every 50 points the snake grows by two segments.
Hopefully the youtube link works
Next will be random placed food item to grow the snake by one segments and 'hazard' mushrooms to avoid.
If I can get that far then I'll 'pretty it up'
https://youtu.be/HYnEcKUBkPM
After 40 years away I'm rediscovering sinclair basic but have also found mcoder2 which is a game changer albeit with it's idiosyncrasies around random number generation!
I never understood machine code as a kid and that is a project for later.
My initial project has been a snake style clone written in basic adapted for and then compiled with mcoder 2
This is week one.
Currently produces a game play area, moving snake, four direction control, both snake and walls have crash detection. Each move increase the score and every 50 points the snake grows by two segments.
Hopefully the youtube link works
Next will be random placed food item to grow the snake by one segments and 'hazard' mushrooms to avoid.
If I can get that far then I'll 'pretty it up'
https://youtu.be/HYnEcKUBkPM
Re: Snake revisit.
Hello,
my suggestion after 40 years:
Skip MCODER2 and start machinecode. Your code will not only be shorter, but it will be faster as well.
If you think it is too hard, start simple.
Make it BASIC first and then convert it step by step into machinecode.
Enough knowledge here to help you out when you get stuck.
my suggestion after 40 years:
Skip MCODER2 and start machinecode. Your code will not only be shorter, but it will be faster as well.
If you think it is too hard, start simple.
Make it BASIC first and then convert it step by step into machinecode.
Enough knowledge here to help you out when you get stuck.
Re: Snake revisit.
Thanks for the advice. It's certainly something I'd like to learn. I was very Concious that other than messing around with an arduino and c++ a couple of years ago I hadn't done any programming since I was a kid so baby steps are going to be needed.
Re: Snake revisit.
Thanks to the help with mcoder2 random number generation my snake clone now sports poisonous mushrooms that kill you on contact and sporadically increase in number and food to make your tail grow.
it's far from pretty or efficient programming but it's mine and the first one I've produced in fourty years
https://youtu.be/wbb29PZ3EDc
it's far from pretty or efficient programming but it's mine and the first one I've produced in fourty years
https://youtu.be/wbb29PZ3EDc
Re: Snake revisit.
Another approach is to make small sub-routines in machine code. The idea is to break down the problem, and test the small routines, before they are combined with the rest of the code. Then combine the program with
Code: Select all
CALL subrutine1
CALL subrutine2
CALL subrutine3
Code: Select all
CALL subrutine4
CALL testConditionForIFandSetZflag
CALL Z subrutineIFflagZisSet
CALL subrutine7
Then you can add
Code: Select all
CALL showregisters
Re: Snake revisit.
Even easier is setting a breakpoint in EughtyOne and do step execution.mrtinb wrote: βWed Feb 08, 2023 8:22 pm
A good idea is also to have a subrutine, that displays the current status of registers and program counter, and stack pointer - without modifying them.
Then you can addmultiple times in your code, when you are trying to find an error.Code: Select all
CALL showregisters
It will give all the info Mrtinnb mentioned.
Re: Snake revisit.
Thanks guys. I'm definitely going to look to progress the machine code thing.
Now that I know I can sort of remember how to program in basic I figure I'll probably look to try the machine code subroutine thing first.
I may use snake as my test bed or I might try some thing a bit simpler to start with.
I've got a small bouncing ball thing I wrote to test out using mcoder a couple of weeks back that might make a useful test project.
Now that I know I can sort of remember how to program in basic I figure I'll probably look to try the machine code subroutine thing first.
I may use snake as my test bed or I might try some thing a bit simpler to start with.
I've got a small bouncing ball thing I wrote to test out using mcoder a couple of weeks back that might make a useful test project.
Re: Snake revisit.
Whilst waiting for my interface parts to arrive i spent a bit of time on this.
Dr Beep will be horrified that it's compiled with mcoder 2 but I'm still at the point of crashing my machine just trying to print simple characters on the screen in machine code The video of it running is here
https://youtu.be/Sk3UDBQXuio
Even compiled from basic it needs significantly slowing down to be playable.
I'm looking forward to being able to code this sort of thing myself without the need of a compiler.
Dr Beep will be horrified that it's compiled with mcoder 2 but I'm still at the point of crashing my machine just trying to print simple characters on the screen in machine code The video of it running is here
https://youtu.be/Sk3UDBQXuio
Even compiled from basic it needs significantly slowing down to be playable.
I'm looking forward to being able to code this sort of thing myself without the need of a compiler.
Re: Snake revisit.
I just saw this contest, in case you are interested in presenting the game
https://itch.io/jam/retro-snake-game-jam
https://itch.io/jam/retro-snake-game-jam
-
- Posts: 169
- Joined: Fri Oct 19, 2018 2:22 am
Re: Snake revisit.
Whitey wrote: βMon Feb 27, 2023 5:15 pm Whilst waiting for my interface parts to arrive i spent a bit of time on this.
Dr Beep will be horrified that it's compiled with mcoder 2 but I'm still at the point of crashing my machine just trying to print simple characters on the screen in machine code
D7CFD77E-FFD1-43FA-96AA-A9E98AF1EDEB.jpeg
The video of it running is here
https://youtu.be/Sk3UDBQXuio
Even compiled from basic it needs significantly slowing down to be playable.
I'm looking forward to being able to code this sort of thing myself without the need of a compiler.
I love the look of this! Any news on it?