Author Topic: [Axe game] 2048  (Read 23852 times)

0 Members and 1 Guest are viewing this topic.

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: [Axe game] 2048
« Reply #45 on: April 20, 2014, 12:01:46 am »
Well I think the official version would be best as long as its not too slow.
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [Axe game] 2048
« Reply #46 on: April 20, 2014, 02:32:23 am »
Well nikitouzz's 2048 has original animations and it is far from being too slow ;)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Toctave

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +2/-0
    • View Profile
Re: [Axe game] 2048
« Reply #47 on: April 20, 2014, 02:35:23 am »
Excuse me guys but would you care discussing this on your own thread since it's kind of unrelated to mine..

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [Axe game] 2048
« Reply #48 on: April 20, 2014, 02:37:29 am »
True, sorry about that :/
But in fact, there are (already) so many 2048 topics that I didn't even notice this was not JW's topic -.-
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Axe game] 2048
« Reply #49 on: April 20, 2014, 04:30:21 am »
Hmmm I thought JWin was offering you some help but w/e. :P

Offline Toctave

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +2/-0
    • View Profile
Re: [Axe game] 2048
« Reply #50 on: April 20, 2014, 06:48:54 am »
Oh dang, ok. I didn't read it that way, thought he offered to add animations in his own game which I found weird. Anyway, I tried to implement animations this way :
-each time there is movement, store the evaluated cell address, the sprite index and the target cell address in a list
-make a for loop with the animation frame as an incrementing variable :
(for left-right movement here)


For(frame, 0, 7)
Check if there's something in the sprite, then
Pt-Off((target-pos)*frame+(pos^4*9+31), pos/4*9+21, sprite)
Pt-On((target-pos)*(frame+1)+(pos*9+31), pos/4*9+21, sprite)
End


Which gives with proper axe syntax :


Code: [Select]
For(J,0,7)
For(I,0,15)
If {I*3+L2}!=0
Pt-Off({I*3+2+L2}-{I*3+1+L2}*J+({I*3+1+L2}^4*9+31),{I*3+1+L2}/4*9+21,{I*3+L2}+Pic0)
Pt-On({I*3+2+L2}-{I*3+1+L2}*(J+1)+({I*3+1+L2}^4*9+31),{I*3+1+L2}/4*9+21,{I*3+L2}+Pic0)
End
End
End

But it doesn't work at all and gives weird results :(
« Last Edit: April 20, 2014, 06:55:23 am by Toctave »

Offline TheCoder1998

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 434
  • Rating: +20/-2
  • my art is written in code, not in graphite
    • View Profile
    • My website :D
Re: [Axe game] 2048
« Reply #51 on: April 20, 2014, 09:57:32 am »
Excuse me guys but would you care discussing this on your own thread since it's kind of unrelated to mine..
well excuuuse me princess :P

[EDIT]
this is a zelda reference btw
« Last Edit: April 20, 2014, 11:25:54 am by TheCoder1998 »
my ticalc acc:

http://www.ticalc.org/archives/files/authors/113/11365.html

Spoiler For The Best Song Ever:


follow me on tumblr :)
www.rickdepizza.tumblr.com

check out my anilist :D
http://anilist.co/animelist/29701/Rickdepizza

Offline Toctave

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +2/-0
    • View Profile
Re: [Axe game] 2048
« Reply #52 on: April 20, 2014, 12:00:07 pm »
This thread...
SO! Can anyone tell me why the code I wrote above doesn't work? 'Cause here's an excel with exemples value that returns the Good numbers, I have no idea why it won't work on calc...

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: [Axe game] 2048
« Reply #53 on: April 20, 2014, 12:31:55 pm »
One thing to be wary of, which it looks like might have tripped you up in your code, is that Pt-Off() is a little bit deceptively named. It does not actually erase a sprite, but in fact draws a sprite (with overwrite logic instead of the OR logic used by Pt-On()). If you actually want to "erase" a sprite, you have to redraw what was behind it on top of it. In this case, I'd say that the easiest thing to do is to re-display the entire board at the start of rendering each frame, overwriting all tiles wherever they may have been last frame.

Also, I think you need a /8 after the multiplications by frame and frame+1.


As an optimization note, you can make division by small powers of two faster, at the cost of size, by chaining together divisions by two, like /2/2/2 for /8. If you divide by the same power of two more than once, you can often mitigate the size cost while keeping most of the speed gains by putting the division into a subroutine and calling that whenever you need to divide by it. You divide by both 8 and 4 in your code snippet, which could be pulled into subroutines that even share the same code:

Code: [Select]
Lbl Div8
/2
Lbl Div4
Return /2/2

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [Axe game] 2048
« Reply #54 on: April 20, 2014, 01:05:31 pm »
You can also evaluate I*3+L2 once and save it into a variable instead of evaluating it 10 times per iteration. You can even forget about this and add 3 to a variable initialized at L2 after every iteration step and replace your For(I,0,15) with a For(16).
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Toctave

  • LV2 Member (Next: 40)
  • **
  • Posts: 22
  • Rating: +2/-0
    • View Profile
Re: [Axe game] 2048
« Reply #55 on: April 20, 2014, 03:24:07 pm »
OK thanks guys this is great
Runer, I can't redraw thé whole board on top of it because I need every celle that moves to be displayed on the buffer before the unique Dispgraph (unique in the big for loop I mean)

About the /8, it's not needed because the pos and target values are not in pixels but in values from 0 to 15. If you open xls you'll sée that this calculus returns the right value

Hayleia, I will do what you said about the variable, but I don't think your second idea really brings anything to the program. However I'm the newbie here :D

Edit : Here's an xls file (That no one will read) that does every calculus using only a pos and target value.
« Last Edit: April 20, 2014, 04:12:09 pm by Toctave »

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [Axe game] 2048
« Reply #56 on: April 24, 2014, 09:50:05 am »
Toctave, here is a little tip : If you're on a phone, try setting your keyboard language to english, the auto-correction will try to correct into english words! ;)  :blah:

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Axe game] 2048
« Reply #57 on: April 24, 2014, 01:21:27 pm »
LOL I get the same issue with thé all the time because I forget to press the language switch. XD

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: [Axe game] 2048
« Reply #58 on: April 24, 2014, 01:23:00 pm »
Kii Keyboard on Android supports primary and secondary language, with correction on both languages without switching ;)
Maybe other keyboards do it too but I know this one does because I use it.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Axe game] 2048
« Reply #59 on: April 24, 2014, 07:06:58 pm »
I just use the AOSP keyboard, it works pretty well. :P