Author Topic: Tunnel clone, with a little twist *runs*  (Read 9765 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Tunnel clone, with a little twist *runs*
« on: April 27, 2010, 02:33:11 am »
Note, 33 fps gif, need Opera/Firefox or a browser supporting gifs higher than 10 fps to view it.

15 MHz speed. Tool-assisted gameplay using WabbitEmu.

Note this is not the official version. The real version has no rickroll and only the title screen has grayscale so gameplay is faster
« Last Edit: April 27, 2010, 02:33:53 am by DJ Omnimaga »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #1 on: April 27, 2010, 03:26:00 am »
Wow!  That's actually really impressive!  And the menu is really cool too.  I especially like how you used grayscale and the speed animation looks really nice.  And of course I get rickrolled in the process  :P
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #2 on: April 27, 2010, 07:30:10 am »
Axe has built in Rick Roll support? Who would have guessed? =P Very fast too!

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #3 on: April 27, 2010, 09:47:06 am »
Heh that is awesome. Not only does it look like a good game because of the actual game play, but the fact that you're getting rick rolled while playing just makes it the ultimate game.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #4 on: April 27, 2010, 11:32:57 am »
lol thanks :P

Last nigth I was curious and wanted to experiment with the grayscale command in the middle of gameplay, seeing how fast it was outside gameplay, and when I saw everything gray remained static, I thought: hey! A nice rickroll occasion! :P

Anyway here's the screenshot of the real version, the official executable and since it's my first Axe game and would like to see what I could optimize (the executable is over 1600 bytes x.x) and also for people learning, I'm also posting the source code.

This simple game was started as I wanted to experiment with the Line() command. Grayscale wasn't even planned initially :P

Note: the game is set to run at the max calc processor speed. Since it was emulated on a 84+SE, it will run twice slower on a regular 83+. However it's still extremly fast on it (and easier to play) :P

Quote from: BASIC Code
:.DJTUNNEL Axe Parser Tunnel clone
:[80C0E0F0E0C08000→Pic1
:[FFFFFFFFFFFFFFFF→Pic2
:"SCORE:"→Str1
:"AXE TUNNEL"→Str2
:"2010, BY DJ OMNIMAGA"→Str3
:"SPEED:"→Str4
:1→S
:9→R
:0→D
:8→C
:30→A+10→W→T
:0→P
:2→Q
:Full
:DiagnosticOff
:ClrHome
:ClrDraw
:For(Z,9,21
:Line(0,Z,95,Z
:End
:Line(0,56,95,56
:StorePic
:ClrDraw
:For(Z,8,22
:Line(0,Z,95,Z
:End
:For(Z,56,63
:Line(0,Z,95,Z
:End
:DrawInv
:Fix 5
:Fix 1
:Text(20,12,Str2
:Fix 0
:Text(14,57,Str3
:Fix 3
:Text(5,35,Str4
:29→I
:5→J
:2→K
:Repeat Z=54
:DS<(K,12)
:DispGraphr
:End
:DS<(J,9/S)
:Pt-Change(I,34,Pic1)
:I+1→I
:If I=86
:29→I
:End
:End
:getKey→Z
:Z=3-(Z=2)+S→S
:If S=6
:5→S
:End
:If S=0
:1→S
:End
:End
:ClrHome
:ClrDraw
:For(Z,10,50
:Line(0,Z,95,Z)
:End
:Repeat W=6 or getKey(15)
:P+S→P
:DS<(C,8)
:If rand<32767
:‾1→D
:Else
:1→D
:End
:End
:R+D→R
:If R<1
:1→R
:End
:If 62-W<R
:62-W→R
:End
:If getKey(4)
:A-1→A
:End
:If getKey(1)
:A+1→A
:End
:Pt-Change(0,A,Pic1)
:Line(95,R,95,R+W)
:DS<(Q,S)
:DispGraph
:If pxl-Test(0,A) or pxl-Test(0,A+6)
:Goto GO
:End
:End
:Pt-Change(0,A,Pic1)
:Horizontal-
:DS<(T,99)
:W-1→W
:End
:End
:Lbl GO
:Fix 4
:Fix 2
:ClrHome
:Output(0,0,Str1,P►Dec
Generated by SourceCoder, © 2005 Cemetech
« Last Edit: April 27, 2010, 11:34:22 am by DJ Omnimaga »

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #5 on: April 27, 2010, 12:19:10 pm »
1600 bytes is OK for an asm game compiled from an 'interlanguage'.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #6 on: April 27, 2010, 12:30:03 pm »
Lol ok :P but yeah I still wanted to show it in case some people got some other tricks to achieve what I did, that could make the code even smaller.

Also I don't use much data. Had this been a game where almost everything is data, the executable would be about twice smaller than the executable.

Offline Silver Shadow

  • Beta Tester
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +27/-7
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #7 on: April 27, 2010, 12:42:34 pm »
the executable would be about twice smaller than the executable.
lolwut?
Former Coder of Tomorrow


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #8 on: April 27, 2010, 12:53:53 pm »
the executable would be about twice smaller than the executable.
lolwut?
In source code, sprites are stored in hex form. A 8x8 sprite takes 16 bytes in the source. When compiled, that sprite shrinks to 8 bytes. Same for any hex data. Say you have a game with 20 KB of map data and 0.5 KB of code. The maps will end up 10 KB and the code around 1 KB

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #9 on: April 27, 2010, 01:05:32 pm »
I did a few optimizations for you, hopefully you'll understand them and catch on.  Most of the other optimizations you can do are with the program flow rather than actually optimizing your code.  For instance, you only use one division routine in the entire code, but you can replace it with a multiplication (High S value corresponds to low speed) instead to avoid needing the routine at all which can saves like 20 bytes or something.

Quote from: BASIC Code
:.DJTUNNEL Axe Parser Tunnel clone
:[80C0E0F0E0C08000→Pic1
:[FFFFFFFFFFFFFFFF→Pic2
:"SCORE:"→Str1
:"AXE TUNNEL"→Str2
:"2010, BY DJ OMNIMAGA"→Str3
:"SPEED:"→Str4
:0→D→P+1→S+1→Q
:8→C+1→R
:30→A
:10→W→T

:Full
:DiagnosticOff
:ClrHome
:ClrDraw
:For(Z,9,21
:Line(0,Z,95,Z
:End
:Line(0,56,95,56
:StorePic
:ClrDraw
:For(Z,8,22
:Line(0,Z,95,Z
:End
:For(Z,56,63
:Line(0,Z,95,Z
:End
:DrawInv
:Fix 5
:Fix 1
:Text(20,12,Str2
:Fix 0
:Text(14,57,Str3
:Fix 3
:Text(5,35,Str4
:29→I
:5→J
:2→K
:Repeat Z=54
:DS<(K,12)
:DispGraphr
:End
:DS<(J,9/S)
:Pt-Change(I,34,Pic1)
:I+1→I
:If I=86
:29→I
:End
:End
:getKey→Z
:Z=3-(Z=2)+S→S
:If S=6
:5→S
:End
:!If S
:1→S
:End
:End
:ClrHome
:ClrDraw
:For(Z,10,50
:Line(0,Z,95,Z)
:End
:Repeat W=6 or getKey(15)
:P+S→P
:DS<(C,8)
:rand^2*2-1→D
:End
:R+D→R
:!If R
:1→R
:End
:If 62-W<R
:62-W→R
:End
:If getKey(4)
:A-1→A
:End
:If getKey(1)
:A+1→A
:End
:Pt-Change(0,A,Pic1)
:Line(95,R,95,R+W)
:DS<(Q,S)
:DispGraph
:If pxl-Test(0,A) or pxl-Test(0,A+6)
:Goto GO
:End
:End
:Pt-Change(0,A,Pic1)
:Horizontal-
:DS<(T,99)
:W-1→W
:End
:End
:Lbl GO
:Fix 4
:Fix 2
:ClrHome
:Output(0,0,Str1,P►Dec
Generated by SourceCoder, © 2005 Cemetech

Edit:
the executable would be about twice smaller than the executable.
lolwut?
In source code, sprites are stored in hex form. A 8x8 sprite takes 16 bytes in the source. When compiled, that sprite shrinks to 8 bytes. Same for any hex data. Say you have a game with 20 KB of map data and 0.5 KB of code. The maps will end up 10 KB and the code around 1 KB
It was funny becasue you said executable was smaller than itself.  You meant the source would be about twice smaller than the executable size.  ;)
« Last Edit: April 27, 2010, 01:10:44 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #10 on: April 27, 2010, 01:49:05 pm »
ooh thanks a lot for pointing those out! The !if ones are stuff I missed but I didn't really realize much ways to do some of the others.

I corrected something in  your version, though:

:30→A
:10→W→T

Changed it to

:30→A
:40→W→T

Else the road ended up 10 pixels large on startup instead of 40

Your optimizations made me discover a few more, too (I moved 29->I, 5->J and 2->K at the top to allow some and make the code more organized). I'll prbly need to re-check the optimization tricks section and the list in the txt file. I couldn't figure out a way to get rid of the division yet without changing the animation speed, but so far I saved 51 bytes, allowing my game to go under 1600 bytes ^^

Thanks again

And
Edit:
the executable would be about twice smaller than the executable.
lolwut?
In source code, sprites are stored in hex form. A 8x8 sprite takes 16 bytes in the source. When compiled, that sprite shrinks to 8 bytes. Same for any hex data. Say you have a game with 20 KB of map data and 0.5 KB of code. The maps will end up 10 KB and the code around 1 KB
It was funny becasue you said executable was smaller than itself.  You meant the source would be about twice smaller than the executable size.  ;)
aaah my bad I didn't notice that typo x.x. He should have pointed it out to me more directly D:
« Last Edit: April 27, 2010, 01:51:00 pm by DJ Omnimaga »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #11 on: April 28, 2010, 03:42:12 am »
Update:

-Did a few more optimizations, thanks to Quigibo for one of them.
-Added highscore support
-Changed some text to lowercases.
-Fixed issue when exiting. Score text would instantly dissapear. Putting a getkey command there fixed it

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #12 on: April 29, 2010, 06:30:51 pm »
finally it's done!

http://www.omnimaga.org/index.php?action=downloads;sa=view;down=528

Future versions may be done for MirageOs/Ion/DoorCS too, but not until I figure out how to get around the bug that causes MirageOs screen to say my game takes 65535 bytes when exited

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Tunnel clone, with a little twist *runs*
« Reply #13 on: April 29, 2010, 07:53:03 pm »
Nice! Looks pretty good. (I haven't tried it yet, but the screeny seems okay.)
This would probably be a good program to make into a tutorial for Axe, since it shows many of its features.
I just wonder how obfuscated the code may have become during optimization...
« Last Edit: April 29, 2010, 07:53:41 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Tunnel clone, with a little twist *runs*
« Reply #14 on: April 29, 2010, 08:06:43 pm »
Maybe it could be put as tutorial indeed. A lot of people start a language by programming a tunnel game. What do you mean by the code being obfuscated, though? Do you think it would be better in a tutorial to show both the code before optimizing and after? Some stuff might be a bit confusing for an early Axe programmer, altough maybe he could be fine by looking at the optimization tricks and table