Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: ClrDraw on November 02, 2013, 02:34:42 pm

Title: Tunnel - by ClrDraw
Post by: ClrDraw on November 02, 2013, 02:34:42 pm
Check out the screenshots for my Tunnel game! Made with Axe 1.2.2. The tunnel gets smaller by one pixel every few seconds until it is about twenty pixels wide. Game is completely random every time you play.
File is attached if you want to download.
Title: Re: Tunnel - by ClrDraw
Post by: mdr1 on November 02, 2013, 03:16:25 pm
Good start !
Title: Re: Tunnel - by ClrDraw
Post by: AssemblyBandit on November 02, 2013, 04:00:41 pm
Damn ClrDraw! It was like just yesterday when you signed up! Nice job on getting stuff out so quick and nice game! +1
Title: Re: Tunnel - by ClrDraw
Post by: TheCoder1998 on November 02, 2013, 04:01:49 pm
looks great, i'm gonna try to program that myself too.
as a kind of exercise ya know  ;D
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 02, 2013, 04:10:43 pm
Lol, thanks!!!  8) I'm adding a few projects I finished a few months before I joined!
Title: Re: Tunnel - by ClrDraw
Post by: Sorunome on November 02, 2013, 04:38:25 pm
Sweet, tunnel games are always fun :D
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 02, 2013, 10:37:40 pm
They are, and it was surprisingly easier to program than many other things I've made!

Spoiler For how it works:
It's one loop, looping through...
the draw subroutine
1. moves everything one pixel to the left
2. random integer 0 or 1, if 0 then the tunnel will move up one and if 1 than the tunnel will move down 1
3. draws the tunnel on the last column (96)
4. every 400 frames makes the Tunnel size one pixel smaller
5. displays graph
6. removes sprite of triangle
the key subroutine
1. if up or down arrows are pressed, moves triangle up or down
2. if clear is pressed, exits
3. pauses the program if on key is pressed, show pause screen
the check subroutine
if there is a pixel where the triangle sprite will be, then gotoEND (player loses, shows high score)
Title: Re: Tunnel - by ClrDraw
Post by: Keoni29 on November 03, 2013, 09:19:44 am
Yeah a tunnel game is a good way to try out a new programming language. It kinda is a benchmark here in the calculator community :P The HP Prime's basic was compared with the CSE one by writing a tunnel game for both of the calcs and playing them side by side.
Title: Re: Tunnel - by ClrDraw
Post by: Xeda112358 on November 03, 2013, 09:48:15 am
Scrolling up/down might actually be about 60% faster than left/right, too. (about 16000 clock cycles versus about 26000).
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 03, 2013, 10:41:25 am
I didn't include left and right. Is that normal to have in a tunnel game?
Title: Re: Tunnel - by ClrDraw
Post by: Keoni29 on November 03, 2013, 11:38:19 am
No he is talking about scrolling the screen vertically vs horizontally :)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 03, 2013, 12:58:23 pm
OH is it really faster? That's really good to know, cause the game is a little slow and I want to speed it up.
Title: Re: Tunnel - by ClrDraw
Post by: Xeda112358 on November 03, 2013, 01:04:56 pm
It is indeed :) Here, check this (http://axe.eeems.ca/Commands.html#screenAndBufferCommands) out and click the little button thing at the bottom to show speed/size for various outputs.

It turns out my estimates were off, though, and it is actually even faster than I predicted :P
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 03, 2013, 01:11:33 pm
Wow that's nce, I'd never paid attention to the size/speed numbers on the right before! I wonder why it's so much faster though?
Title: Re: Tunnel - by ClrDraw
Post by: Xeda112358 on November 03, 2013, 01:18:32 pm
Internally, the calculator stores the screen buffer as a 768 byte array. Each byte corresponds to 8 pixels (8 bits per byte) and the screen is horizontally aligned, meaning the first 12 bytes (96 pixels) correspond to the top row and it works down the screen from there.

To scroll the screen down or up, we only need to shift 12 bytes which is pretty easy to do-- there is an instruction that lets us copy a number of bytes from one location to another, removing a lot of overhead code.

To scroll the screen left or right, we need to shift by 1 pixel and there is no easy instruction to do that. In fact rotating or shifting bits requires an extension of the instruction set, which makes it even slower to rotate by bits. (shifting by 8 pixels left or right is much easier as that becomes once again, shifting the buffer by a byte, which is easy)

Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 03, 2013, 01:52:50 pm
That's really interesting, I was wondering how it stored it recently.
Title: Re: Tunnel - by ClrDraw
Post by: Runer112 on November 03, 2013, 03:50:48 pm
Tip: Use #ExprOn (that's normally the ExprOn token) anywhere before Horizontal+/- in your program and it becomes pretty much just as fast as Vertical+/-, at the cost of a 28-byte larger, speed-optimized routine. A few other routines have speed-optimized versions and also get speed benefits (with size costs) from #ExprOn, including ►Hex, DrawInv, and multiplication, and additionally Pt-On(), Pt-Change(), and Pt-And() if not compiling your code as an application.

If you want to speed it up even more, shift in more than one pixel per new frame. Each additional pixel shifted and redrawing of the tunnel will of course make each frame take longer to render and thus decrease the framerate, but you might be able to get away with a couple extra shifts per frame without noticeable choppiness.
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 03, 2013, 06:27:22 pm
I didn't want to make is shift twice per frame because it would be too fast and choppy, but I forgot about #ExprOn and #ExprOff  :)
Title: Re: Tunnel - by ClrDraw
Post by: DJ Omnimaga on November 03, 2013, 07:34:33 pm
They are, and it was surprisingly easier to program than many other things I've made!

It depends with which language, though. With xLIBC it's even harder than a tilemap O.O (due to the whole screen shifting looping issue).

Anyway this is a good start, plus you have it scroll at 1 pixel interval. :)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 04, 2013, 04:46:24 pm
Thanks  :)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 04, 2013, 09:31:39 pm
Whenever I upload it to the download section it always says that the file can not be found, and I always select the file. Why doesn't it work? What am I doing wrong  :-\
I eventually just included a link to my other website...
http://www.omnimaga.org/index.php?action=downloads;sa=view;down=868 (http://www.omnimaga.org/index.php?action=downloads;sa=view;down=868)
EDIT1: OH, do I have to fill out the upload url in addition to choosing the file?
EDIT2: I found a way to put the download link from my own site so it works normally... It's still weird that the regular choose file button didn't work.

(oh and sorry I replied twice in a row, I didn't notice)
Title: Re: Tunnel - by ClrDraw
Post by: AssemblyBandit on November 04, 2013, 10:07:04 pm
I think its easier to just use the url link anyway!
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 04, 2013, 10:12:28 pm
Totally! I must've edited the darn thing like 20 times trying to get choose file to work  XD
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 08, 2013, 04:47:43 pm
Hmmm, you wouldn't perhaps mind if I ported this to the TI-Nspire, would you?

Great job, by the way, just wanted permission because I think that some of my friends would love a game like this!  :thumbsup:

(Of course I'll have your name first in the credits, duh!)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 08, 2013, 05:08:47 pm
Quote
Hmmm, you wouldn't perhaps mind if I ported this to the TI-Nspire, would you?

Of course you can :) this particular game wasn't very hard to code so I made it completely open source.
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 08, 2013, 05:17:24 pm
Quote
Hmmm, you wouldn't perhaps mind if I ported this to the TI-Nspire, would you?

Of course you can :) this particular game wasn't very hard to code so I made it completely open source.

Awww, yea! Expect to see one soon, in COLOR :D
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 08, 2013, 05:31:02 pm
Haha, it's getting serious now  XD I'm getting a color ti soon, I can't wait to try it out!
Title: Re: Tunnel - by ClrDraw
Post by: LDStudios on November 08, 2013, 05:33:56 pm
Quote
Hmmm, you wouldn't perhaps mind if I ported this to the TI-Nspire, would you?

Of course you can :) this particular game wasn't very hard to code so I made it completely open source.

Awww, yea! Expect to see one soon, in COLOR :D

Making it for ndless like your Hexaspire? or will it be in lua
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 08, 2013, 05:42:14 pm
I think Ndless. I like its speed over lua, as lua in interpreted rather then native. I might make a lua program in the future. I almost have it done pretty much too!  :thumbsup:
Title: Re: Tunnel - by ClrDraw
Post by: LDStudios on November 08, 2013, 05:45:12 pm
Sounds good! :)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 08, 2013, 05:52:36 pm
I saw your Hexaspire earlier today btw, it looks really awesome. I wanted to make one for the ti when I first saw my friend playing it on his phone last year, but I didn't even know where to start! Good luck with it  :thumbsup:
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 08, 2013, 06:39:05 pm
I hope someone finishes it for the ti 84! Would really love to see it on that calculator!
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 08, 2013, 06:48:28 pm
I should give it a shot after I finish AlphaCS... IDK how to get the special effects though 0.0
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 08, 2013, 06:50:49 pm
Shoot, I would love to finish programming your game, but it will have to be postponed 'til like... tomorrow afternoon :D

Would love to see someone give it another shot!
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 08, 2013, 06:55:48 pm
Haha  8) same!
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 09, 2013, 10:23:33 pm
I'm back and I'm almost done! Just have to make a message box that pops up!

Like this: http://ourl.ca/20004/366709 (http://ourl.ca/20004/366709)
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 10, 2013, 11:00:16 am
That's really awesome, I love how it says the points in the top left (ClrDraw kicks himself for not doing that in his version)  :thumbsup: and dang, good job getting that out so fast! You should put your name first though, you did all the hard work.
Title: Re: Tunnel - by ClrDraw
Post by: RedHat on November 10, 2013, 11:25:21 am
Well, maybe, but I think you are pretty awesome for making it in the first place. There is an... interesting bug where if you press down too much in the beginning yu'll go off the screen D:

I'll fix that today, it's a silly bug but then again I only worked on it for like... 3 hours XD
Title: Re: Tunnel - by ClrDraw
Post by: ClrDraw on November 10, 2013, 01:40:34 pm
Ooo, press down in the beginning you say?

(ClrDraw plots how to get the high score)