Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: JWinslow23 on May 22, 2014, 08:15:13 pm

Title: TI-2048 by Josiah W.
Post by: JWinslow23 on May 22, 2014, 08:15:13 pm
I have worked for months on this game, and it is FINALLY ready for a release! ;D
Click the gif image to jump to the latest version!

TI-2048
Join the numbers and get to the 2048 tile!
(http://img.ourl.ca/TI2048-1-1.gif) (http://ourl.ca/21133/385057)
HOW TO PLAY: Use your arrow keys to move the tiles. When
two tiles with the same number touch, they merge into one!

NOTE: This is not the official version of 2048; it is simply a port.
You can play the original at http://git.io/2048 (http://git.io/2048). All other apps or
sites are derivatives or fakes, and should be used with caution.

Port created by Josiah Winslow, with help from the Omnimaga
community. Original game created by Gabriele Cirulli (http://gabrielecirulli.com/). Original
based on 1024 by Veewo Studio (https://itunes.apple.com/us/app/1024!/id823499224) and conceptually similar to
Threes by Asher Vollmer (http://asherv.com/threes/).

Please help me with optimizations and play testing, everyone! Give me any suggestions you can! Seriously, my code is kinda hackish right now. XD

NOTE: This requires A2048 and LIB3BYTE on your calc to compile properly. I'll compress it soon, I promise.
This also saves your highscore in an appvar called "TI2048". It is automatically archived upon exit.

Spoiler For Credits:
Hayleia for providing tile graphics, and moral support.
Runer112 for general support, a library giving me access to 3-byte numbers, and giving me the sliding algorithm that eluded me for SO long! I know I told you this before with another project, but this would only have been an idea without you!
willrandship for...something I forget. Optimization? :/ I swear, this project is really taking a toll on my memory.
The whole Omnimaga community for giving me support along the way!

Spoiler For Version History:
v1.0: 5,761 bytes. Initial release.
v1.1: 5,845 bytes. Fixed score display bug upon win.
Title: Re: TI-2048 by Josiah W.
Post by: Joshuasm32 on May 23, 2014, 12:01:33 am
That's very nice, and fast too!  Good work.  :)
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on May 23, 2014, 12:18:21 am
Looks very nice and fun to play. Good job on this program :)
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 23, 2014, 12:32:14 am
Thanks, both of you. :)
Now for some optimization... *cough*MatrefRunerHayleia*cough*
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on May 23, 2014, 12:41:58 am
FINALLY ! I thought my graphics would be of no use.
jk :P

Glad to see it out :)
However, I won't be able to help with optimization before two weeks (exams), sorry -.-
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 23, 2014, 12:47:10 am
That's OK, Hayleia. I can wait.
Meanwhile, time to try some things of my own...
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on May 23, 2014, 12:50:36 am
Optimization practicing is always good :)
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on May 23, 2014, 02:28:02 am
NOTE: This is not the official version of 2048; it is simply a port.
You can play the original at http://git.io/2048 (http://git.io/2048). All other apps or
sites are derivatives or fakes, and should be used with caution.
Lol. ;D
Nice to see it finished at last. :D
Title: Re: TI-2048 by Josiah W.
Post by: Sorunome on May 23, 2014, 10:45:10 am
Nice to see this complete!
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 23, 2014, 07:42:10 pm
Well, I'm not done yet...there's still some stuff I wanna add... >:D
But yeah, tell me what you think of the gameplay and stuff like that.
Title: Re: TI-2048 by Josiah W.
Post by: bb010g on May 23, 2014, 11:12:38 pm
Looking good! I like the smoothness. :)

Port created by Josiah Winslow, with help from the Omnimaga
community. Original game created by Gabriele Cirulli (http://gabrielecirulli.com/). Original
based on 1024 by Veewo Studio (https://itunes.apple.com/us/app/1024!/id823499224) and conceptually similar to
Threes by Asher Vollmer (http://asherv.com/threes/).


*cough*THREESMASTERRACE*cough*
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 24, 2014, 12:07:30 am
Why did you direct me to http://games.usvsthm.com/2048/masterrace-edition/ , bb010g? :P But yeah, I worked on the animations a LONG time. O.O
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on May 24, 2014, 04:18:13 am
I just tried it now. I have to say the graphics are awesome (/me runs :P) but why are animations not that smooth ? They seem to move by 2 pixels each frame instead of one and they seem to be slower when more tiles move.
Title: Re: TI-2048 by Josiah W.
Post by: Runer112 on May 24, 2014, 09:56:16 am
I just tried it now. I have to say the graphics are awesome (/me runs :P) but why are animations not that smooth ? They seem to move by 2 pixels each frame instead of one and they seem to be slower when more tiles move.

I'm assuming that was to remedy the previous issue with animations being much slower, to the point where they would probably interfere with gameplay. I'd rather have a slightly choppy animation that finishes quickly than one that's smooth but puts a significant limit on playing speed.
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on May 24, 2014, 10:07:38 am
Well yeah but nikitouzz's version doesn't have those lags. Ok, this one is in grayscale and has bigger sprites but that shouldn't slow it that much, should it ?
Title: Re: TI-2048 by Josiah W.
Post by: Runer112 on May 24, 2014, 10:13:57 am
After comparison, I see what you mean. It's a bit choppier, although that gif is making it look choppier than it really is.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 24, 2014, 06:52:28 pm
Runer, that was the fix for the problem, yes. But personally, I preferred the smoother animation.
Hayleia, the anim looks fine to me on-calc. Because everyone was asking for fast animations, it now moves 4 pixels at a time. Happy now, everyone? :P
Title: Re: TI-2048 by Josiah W.
Post by: TheCoder1998 on May 25, 2014, 09:16:03 am
I must say that this is my favourite 2048 port right now :)
great job!
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 25, 2014, 12:10:52 pm
Well, thanks! :)

BTW, I have a section of code that I'm having a bit of trouble optimizing. The code to display whether or not you win or lose is the same, except for a few minor differences. The problem is, I've never been able to combine them. Help? :/
Title: Re: TI-2048 by Josiah W.
Post by: TheCoder1998 on May 26, 2014, 05:04:10 am
Why don't you upload the game to ticalc?
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 26, 2014, 12:15:45 pm
My game isn't fully optimized yet. Usually, I hold a release on ticalc until my games are working and my code is the smallest possible. Heck, I waited until version 2.2 to release my Flappy Bird clone! :P

So, anybody that can help with optimizations, please do if you want this on ticalc!
Title: Re: TI-2048 by Josiah W.
Post by: chickendude on May 28, 2014, 07:59:23 pm
Why do you save the high score in an AppVar? It can't be more than 2 bytes. Just add two empty bytes in your program and save it there, ion/whatever shell you use will take care of the SMC for you. If you want it to be nostub you can do the SMC yourself by finding the program in RAM and overwriting the two high score bytes. People these days are AppVar crazy ;) Anyway it looks really great, i'm going to download this now and send it to me calc :)
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on May 29, 2014, 02:05:01 am
Score is 3 bytes here, not 2. It's not a lot more but I just wanted to point it out :P

Also, there are reasons why people are "appvar crazy". First of all, not everyone use a shell (I think about people stuck with a regular 83+ and who want to save as much space as possible), so except if we do the SMC ourself as you said, which is a lot more annoying for not so much, we can't save the highscore for everyone. Second of all, SMC requires to re-archive the whole program at exit, while saving in appvar just requires to re-archive the small appvar, so it has two advntages. The first one being that exiting is faster, the second one being that garbage colleting happens less frequently (I still think about people stuck with  aregular 83+).
At least, those are the reasons why I use appvars, I don't know if everyone do it for the same reasons ;)
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on May 29, 2014, 02:08:24 am
Yeah I remember having to Garbage Collect after every Mario execution >.<
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on May 29, 2014, 04:17:32 am
Also, in a PC game would you do SMC for a high score ? No because SMC is ugly. :P
Title: Re: TI-2048 by Josiah W.
Post by: chickendude on May 29, 2014, 08:30:01 am
Haha but this isn't a PC game, and (practically) every Gameboy game uses it. Also, the majority of games are written for shells, and if you have an 83+ games written for shells will be smaller since they can reuse (probably Ion's) sprite code. It's also not much code to implement yourself. And using SMC here would be smaller than using an AppVar, as the AppVar takes up 9 bytes in RAM (for the VAT entry) and 3 bytes in archive (plus all the code to handle the AppVar). I guess it's not really a big deal, i just prefer having everything in one program when it's possible/convenient.

@JWinslow23: I just loaded this up on my calc, it looks and works great, i was proud of myself for getting to 512 :D
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on May 29, 2014, 03:10:53 pm
He's right. You could just tore the score and stuff to a GDB. :P I just like Appvars; that way, scores and boards could be transferred between calcs without a different program file.

chickendude, I'm glad for you! The highest number I ever got was 4096. I'm still working on getting an actual 3-byte score.
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on May 29, 2014, 04:00:07 pm
I'm currently at 32768 on my phone and still didn't lose. :trollface:
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 01, 2014, 04:10:11 pm
I fixed a score display bug! When you win (or make a merge right before a GAME OVER), it doesn't update the score display until you continue (or if GAME OVER, not at all).
I would really appreciate it if I could get help with optimization, though. Cause really, I'm getting nowhere. ???

Download in the attachments. A2048 and LIB3BYTE must be present on your calc to compile.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 07, 2014, 06:41:35 pm
Bump.

I'm really surprised that not many people are paying attention to this as much as they did Flappy Bird. It's like everybody that looked at this just said "Oh, he finished, that's nice" and disregarded this. I worked for months on this (much less than I did Flappy Bird), and am kinda surprised how bad this game is doing.
21 all-time downloads for any version of either of the 2048 source files, and 15 downloads for any version of the Noshell compiled result, as compared to 44 all-time downloads for the Flappy source and 82 downloads for any version of the Noshell compiled result (which doesn't include any versions prior to v1.10), not to mention 204 Flappy DLs on ticalc.

Don't take any of the above the wrong way, though. It's nice to have the people that commented and looked say the things they said and do the things they did, but for some reason, this isn't as popular now as I thought it'd be. Please don't hate me. :/

I'll release the file to ticalc as soon as I am certain that this program is at its fastest and/or smallest. There are some spots that I'm unsure of whether or not to optimize.
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on June 07, 2014, 06:50:15 pm
I don't hate you. ???
Nah that aside, I kinda forgot about it because I play 2048 when bored and I don't bring my calcs everywhere. :P So I play on my phone.
also undo button
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 07, 2014, 07:23:13 pm
Well, there's something different. I don't even HAVE a phone! XD

I said "Please don't hate me" because I thought that kinda sounded like "Hey, everyone! Notice me!", and I didn't wanna sound so much like I craved attention. If that makes sense. x.x
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on June 07, 2014, 08:06:31 pm
I understood that. :P I was just messing with you.
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on June 08, 2014, 02:51:30 am
I think the issue with this game is that the 2048 craze went on for shorter than Flappy Bird. You Flappy bird clone was not the first ever made for calcs, but Flappy Bird remained popular for long enough to allow your remake to thrive. However, your 2048 clone came out as the 2048 fad was dying. It's definitively one of the best looking for calcs, though (same for your Flappy clone).
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on June 08, 2014, 03:28:56 am
Well I expressed the two issues I had with that game. The first one was the graphics, and I helped you with that. The second one is the speed of animations. First of all they are not 1px per frame but 2px per frame, and most of all they are not at a constant speed (slower when more tiles are on the board).

So of course I don't hate you ;)
But when I check that topic, either I see "that issue is fixed" or I don't see it. I am not expecting anything more, everything else is great.
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on June 08, 2014, 09:46:44 am
I actually thought the animations were fine. Some are less smooth than Nikitouzz version but the game looks nicer in overall. It's most likely due to grayscale, though (but again Reuben has perfect grayscale and still run fast :P).
Title: Re: TI-2048 by Josiah W.
Post by: chickendude on June 08, 2014, 10:50:31 am
Reuben also just has one moving object on the screen ;) And at least the latest version runs perfectly fast, i think it jumps 4 pixels at a time and at that speed you can't really notice any slowdown.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 08, 2014, 09:00:07 pm
Well, Flappy Bird was only so popular so long because because of the removal from the App Store, and remakes were highly sought after. Gabriele still has HIS on the app store, and even if he didn't, his official online version remains, leaving less demand for any remakes. :P


Anyways, glad to get more feedback. I guess I'll put it on ticalc now. Expect a release on ticalc within the week!
Title: Re: TI-2048 by Josiah W.
Post by: bb010g on June 08, 2014, 09:09:25 pm
I don't hate you. ???
Nah that aside, I kinda forgot about it because I play 2048 when bored and I don't bring my calcs everywhere. :P So I play on my phone.
also undo button
UNDO BUTTON? UNDO BUTTON? WE DON'T NEED NO STINKIN' UNDO BUTTONS! :3

JWinslow23: You hit the end of the craze. Personally, I would use your version, but I don't have a 84.
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on June 08, 2014, 10:42:40 pm
If Omni ever allows new downloads again you should put a copy there too, or you could ask staff via ourl.ca/request to get the game added.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 09, 2014, 12:25:49 pm
DJ Omnimaga: You mean added to the featured game list? That'd be cool. :D (However, I believe that if anything of mine should've been featured, I'd prefer it to be Flappy Bird 84+. :P )

bb010g: Well, thanks...oh, and an 84+ will be well worth the money. ;)

Everyone who's complaining about the slow anims: This is why I need optimization. :P
I mean, I'm doing a lot of calculations when the moves occur. I'm using grayscale. I'm doing 3 byte scores. My graphics are 15x15 Bitmaps. There has to be a Game Over check and Win check after every move. There are probably some snippets of code I'm not sure I need, like a use of the abs() token somewhere in the animations. What do you expect in terms of instantaneosity? :P
Title: Re: TI-2048 by Josiah W.
Post by: Hayleia on June 09, 2014, 01:24:54 pm
Everyone who's complaining about the slow anims: This is why I need optimization. :P
I mean, I'm doing a lot of calculations when the moves occur. I'm using grayscale. I'm doing 3 byte scores. My graphics are 15x15 Bitmaps. There has to be a Game Over check and Win check after every move. There are probably some snippets of code I'm not sure I need, like a use of the abs() token somewhere in the animations. What do you expect in terms of instantaneosity? :P
Calculations should occur before the move, so you just have to move afterwards. 3 bytes score and Win/Loss checks have nothing to do with animations. The only things that can slow down are the grayscale and the 15x15 bitmaps (which could be replaced with 4x 8x8 sprites).
And once again, what I complain about isn't the general slowness, which your two arguments could explain, but the fact it is slower when more tiles move, which is very annoying and this is probably an algorithmic problem, not an Axe optimisation one. In other words, I don't care if it runs at 1 FPS as long as it is a constant 1 FPS, and not 60 FPS first then 1 FPS when I played more.

And I'd gladly help you if I didn't have enough to do with school projects -.-
Seriously, I envy those people in French high schools who only have the Bac and have plenty of free time compared to what I have.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 09, 2014, 05:04:49 pm
Here, then, is the algorithm for animation.

1. Initialize X and Y positions (stored in GDB1, copied and manipulated to L1).
2. Calculate how many squares a tile has moved in any direction.
3. Repeat this 4 times:
3a. For every tile, adjust the X and Y values of each tile animated 4 pixels in the direction you slid (determined by K).
3b. Draw the tiles.
3c. End Repeat

And the subroutine code (GDB1 is the X values of every tile, then the Y values):
Code: [Select]
.Just so we're clear, GDB1 is:
.0,16,32,48,0,16,32,48,0,16,32,48,0,16,32,48,0,0,0,0,16,16,16,16,32,32,32,32,48,48,48,48
.That should clear some stuff up.
.
Lbl ANIM
Copy(GDB1,L1+48,32)
0->[r3]
For(16)^^r
abs([r3]-{[r3]+32+L1})->{[r3]+32+L1}
[r3]++
End
For(4)^^r
15
For(16)^^r
Rect(->[r3]^4*16,[r3]/4*16,15,)^^r
[r3]-1
End
For(16)^^r
[r3]+48+L1->[r4]
[r4]+16->[r5]
If {[r3]+16+L1}
WRect({[r4]},{[r5]},15,)^^r
Bitmap({[r4]},{[r5]},{[r3]+16+L1}-1*32+Pic1)
End
!If K
{[r5]}+({[r3]+32+L1})->{[r5]}
Else!If K-1
{[r4]}-({[r3]+32+L1}*4)->{[r4]}
Else!If K-2
{[r4]}+({[r3]+32+L1}*4)->{[r4]}
Else
{[r5]}-({[r3]+32+L1})->{[r5]}
End
[r3]++
End
DispGraph^^r
WRect(0,,63,)
End

There are definitely stuff I could improve upon, but I don't believe that a full algorithm rewrite is absolutely necessary.


If you need anything else, just tell me.
Title: Re: TI-2048 by Josiah W.
Post by: Streetwalrus on June 09, 2014, 05:55:28 pm
I don't hate you. ???
Nah that aside, I kinda forgot about it because I play 2048 when bored and I don't bring my calcs everywhere. :P So I play on my phone.
also undo button
UNDO BUTTON? UNDO BUTTON? WE DON'T NEED NO STINKIN' UNDO BUTTONS! :3

JWinslow23: You hit the end of the craze. Personally, I would use your version, but I don't have a 84.
Welp I managed to reach 131072 (the max tile) with the undo button but it was still challenging and it took forever. Fwiw, that's 64x2048.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on June 18, 2014, 03:06:06 pm
Bump.

Two things:
1. The "inconstant speed" Hayleia's talking about is actually a main feature of my animation algorithm. It's not running any slower or faster in terms of speed; the TILES are.
How my code works is: tiles move a certain speed towards their targets depending on their distance (a la the original). Therefore, it makes sense that the less tiles on the screen, the faster it seems; that means tiles may move a greater distance, and with a greater "speed". And this also stands with the more tiles on the screen, the less of a distance the tiles move, the slower it seems to go.
2. I've been tinkering with an AI (I don't think this will be developed any further than it is, however) that basically makes the move that merges the most tiles. Download attached (LIB3BYTE not included). Use the STO key to make a move with the AI.
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on July 09, 2014, 03:22:53 pm
Bump.


Released on ticalc.org. http://www.ticalc.org/archives/files/fileinfo/460/46046.html
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on July 09, 2014, 11:55:56 pm
I should put this on my calc when I have time. I would like to try all 2048 Axe clones, though. I wonder how good the grayscale in yours look like on a real calc.

Also, how are the small fonts done? Are they custom fonts or is this just an image?
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on July 10, 2014, 01:56:39 pm
I should put this on my calc when I have time. I would like to try all 2048 Axe clones, though. I wonder how good the grayscale in yours look like on a real calc.

Also, how are the small fonts done? Are they custom fonts or is this just an image?
Well, the grayscale looks fine on an actual calc.

And the small fonts you are talking about? Those are all Bitmaps, drawn with the Bitmap() command. Every "block" of text that is not an original TI font is drawn with a Bitmap of some sort. (It's the only way I could get everything I wanted to fit to fit!)
Title: Re: TI-2048 by Josiah W.
Post by: chickendude on July 16, 2014, 10:14:44 pm
The grayscale looks really nice on calc. Personally this is my favorite of the 2048 clones :)
Title: Re: TI-2048 by Josiah W.
Post by: DJ Omnimaga on July 17, 2014, 12:40:12 am
I should put this on my calc when I have time. I would like to try all 2048 Axe clones, though. I wonder how good the grayscale in yours look like on a real calc.

Also, how are the small fonts done? Are they custom fonts or is this just an image?
Well, the grayscale looks fine on an actual calc.

And the small fonts you are talking about? Those are all Bitmaps, drawn with the Bitmap() command. Every "block" of text that is not an original TI font is drawn with a Bitmap of some sort. (It's the only way I could get everything I wanted to fit to fit!)
Ah ok thanks for the info. :D
Title: Re: TI-2048 by Josiah W.
Post by: JWinslow23 on July 17, 2014, 01:15:15 am
Thanks, chickendude. It's just Dispgraph^^r, but thank you. XD