Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Toctave

Pages: 1 [2]
16
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:53:11 am »
Well you talked about updating (that's the god damn word  :w00t: ) the buffers, not the text only. Anyway, now i understood.


Edit : ninja'd my sidenote...
Edit 2 : Get Rid of it? like using sprites to display the text?

17
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:49:37 am »
Ok that worked, thanks.
However, about the Text again, my Buffer actualisation (is that even a word in english?) needs to be in a fast enough loop to show grayscale, loop which the text slows down a lot... Maybe I'll try to actualise (...) the text only when needed.

18
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:45:23 am »
Try manually GCing.
Yeah sure I should try that WTF are they talking about...

19
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:39:48 am »
I have a TI-83+ (fr), and it says I have 86651 bytes of free archive...

20
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:37:15 am »
Ok that's done, now I'm trying to solve that text problem.
On an unrelated note, how do I avoid Garbage Collecting everytime I compile my program?

21
Introduce Yourself! / Re: hi.
« on: April 14, 2014, 10:18:10 am »
Ok see you guys later on the forum as late as possible :D

22
Axe / Re: [Axe game] 2048
« on: April 14, 2014, 10:13:44 am »
Thanks Sorumone, Streetwalrus this seems like a good idea, however how should I initialize this PicX? By putting "-> {PicX + 1,2,3,4...}" instead of "-> Pic1, Pic2, Pic3, Pic4..."?
About the text issue, I think I know why it does this. It's because there's no way to write Text on the buffer only, and in a fast enough way. I think drawing Text is just horribly slow :( . What do you mean exactly by "play around with ClrDraw"?

23
Introduce Yourself! / Re: hi.
« on: April 14, 2014, 10:11:19 am »
Can anyone tell me where this peanut thing comes from?

24
Introduce Yourself! / hi.
« on: April 14, 2014, 10:03:18 am »
hi.
I'm Toctave, a 15 years old french student, I don't program much (mostly during class :angel: ), and almost only program in Axe Parser. For now I've just gone to this forum to get some help with axe parser but now that I have my own account I should be able to really be a part of the community :D

25
Axe / [Axe game] 2048
« on: April 14, 2014, 09:39:41 am »
Hi guys!
I recently created a game in axe, you probably know it, it's 2048.
So here's the code with as much comments as I thought were needed, don't hesitate about asking me about a part of it if it's not clear enough.


Variables :
Pic** : Sprites and Bitmaps
I, J, K : Counters for the For( loops in movements subroutines
L1 : Pointer to the game table. I store the cells as their power of 2 (e. g. 2 is 1, 64 is 6, and 2048 is 11)
appvA : 20 bytes appvar to save the current game table, score, and high score
Q : Pointer to appvA
theta : If it's non zero, at least one cell has moved (helps to know when to create new cells)
N : limit variable, explained below
V : Value of the evaluated cell
T : Value of the targetted cell

Code: [Select]
.A2048
.Sprite for the Tiles
[FF818181818181FF]->Pic0
[FF818199998181FF]->Pic1
[FF8189B99D9181FF]->Pic2
[FF81FF8181FF81FF]->Pic3
[FF81BDA5A5BD81FF]->Pic4
[FFA5FFA5A5FFA5FF]->Pic5
[FF9999FFFF9999FF]->Pic6
[FFC3A59999A5C3FF]->Pic7
[FFC3BDBDBDBDC3FF]->Pic8
[FFFFC3DBDBC3FFFF]->Pic9
[FFFFFFE7E7FFFFFF]->Pic10
[FFABD5ABD5ABD5FF]->Pic11
[FFFFFFFFFFFFFFFF]->Pic12
.Logo Bitmap
Data(40,16)->Pic0A
[FFFFF0FF00818190818081819F8180F999999980F999999980819981818081998181809F99F999809F99F9998081818981808181898180FFFF8FFF807FFF87FF80000000000000000000000000000000]
.Help screen Bitmaps
Data(16,56)->Pic0B
[FF00810081609910992081408170FF000000FF0081008940B9509D7091108110FF000000FF008100FF7081508170FF508170FF000000FF008100BD23A564A527BD258177FF000000FF00A500FF66A511A522FF14A567FF000000FF0099009934FF45FF7799519971FF00000000000000]
Data(24,56)->Pic0C
[0000FF0000C304CEA50C2A99044E99048AA50EEEC30000FF0000000000FF0000C30CE6BD0288BD04CEBD082ABD0ECEC30000FF0000000000FF0000FF0E4CC308C2DB0C44DB0248C30CEEFF0000FF0000000000FF0000FF44C8FFCA2AE74A4EE74A82FFE4E2FF0000FF0000000000FF0000ABC48ED52AAAAB4AEED58A2AABE42ED50000FF0000000000FF0000FF84E6FFAAA8FFEAEEFF2A2AFF24CEFF0000FF000000000000000000]
DiagnosticOff
ExprOn
Full

Fill(L1,16,0)
0->I->J->K

.Default value for the NEW subroutine, see below
1->{L1+16}

.Create or load an appvar for the game table
UnArchive "appvA"
!If GetCalc("appvA"
GetCalc("appvA",20)->Q
R()
Else
GetCalc("appvA")->Q
End

.Recover last session
LOAD()

.Main Loop
Repeat getKey(15)
If getKey
If getKey(1)
DOWN()
End
If getKey(2)
LEFT()
End
If getKey(3)
RIGHT()
End
If getKey(4)
UP()
End
If getKey(55)
R()
End
If getKey(54)
H()
End
End
D()
End
If S>{Q+18}^^r
S->{Q+18}^^r
End
SAVE()
Return


Lbl DOWN
.By default, no move has been done
0->theta
.Check all columns (J)
For(J,0,3)
3->N
For(K,1,3)
.K is used to make a For( loop with I from 3 to 1
.X is the address of the target cell, it's by default the cell below the evaluated one
3-K->I+1->X
.If the evaluated cell contains a number
If {4*I+J+L1}->V!=0
.Main loop to find a target position
.Find a cell with the same value as the evaluated cell
.or an obstacle
.or X reaches the limit
Repeat {4*X+J+L1}->T=V or (T!=V and (T!=0)) or (X=N)
X++
End
{4*X+J+L1}->T
.If an obstacle was found, the target cell is one row upwards
If T!=V and (T!=0)
X--
End
.If any movement is made (target cell is different from evaluated cell)
If X!=I
.If target cell is empty
If {4*X+J+L1}=0
V->{4*X+J+L1}
Else
.If we're there, the target cell value needs to be increased
V+1->{4*X+J+L1}
.And the limit value goes upwards (see in the message for more information)
X-1->N
e^(V+1)+S->S
End
.Empty the evaluated cell and tell the program a move has been made
0->{4*I+J+L1}
theta++
End
End
End
End
.If at least one move has been made, create a new cell
If theta
NEW()
End
Return

Lbl LEFT
0->theta
For(J,0,3)
0->N
For(I,1,3)
If {4*J+I+L1}->V!=0
I-1->X
Repeat {4*J+X+L1}->T=V or (T!=V and (T!=0)) or (X=N)
X--
End
{4*J+X+L1}->T
If T!=V and (T!=0)
X++
End
If X!=I
If {4*J+X+L1}=0
V->{4*J+X+L1}
Else
V+1->{4*J+X+L1}
X+1->N
e^(V+1)+S->S
End
0->{4*J+I+L1}
theta++
End
End
End
End
If theta
NEW()
End
Return

Lbl RIGHT
0->theta
For(J,0,3)
3->N
For(K,1,3)
3-K->I+1->X
If {4*J+I+L1}->V!=0
Repeat {4*J+X+L1}->T=V or (T!=V and (T!=0)) or (X=N)
X++
End
If (T!=V and (T!=0))
X--
End
If X!=I
If {4*J+X+L1}=0
V->{4*J+X+L1}
Else
X-1->N
V+1->{4*J+X+L1}
e^(V+1)+S->S
End
0->{4*J+I+L1}
theta++
End
End
End
End
If theta
NEW()
End
Return

Lbl UP
0->theta
For(J,0,3)
0->N
For(I,1,3)
I-1->X
If {4*I+J+L1}->V!=0
Repeat {4*X+J+L1}->T=V or (T!=V and (T!=0)) or (X=N)
X--
End
{4*X+J+L1}->T
If T!=V and (T!=0)
X++
End
If X!=I
If {4*X+J+L1}=0
V->{4*X+J+L1}
Else
X+1->N
V+1->{4*X+J+L1}
e^(V+1)+S->S
End
0->{4*I+J+L1}
theta++
End
End
End
End
If theta
NEW()
End
Return

Lbl SAVE
Copy(L1,Q,16)
S->{Q+16}^^r
Return

Lbl LOAD
Copy(Q,L1,16)
{Q+16}^^r->S
Return

Lbl NEW
.L is set to 16 so the new cell position changes everytime
16->L
Repeat {L1+L}=0
rand^16->L
End
rand^6/5+1->{L1+L}
Return

Lbl R
0->S
Fill(L1,16,0
NEW()
NEW()
Return

Lbl H
.Clear the screen and draw the help bitmaps
ClrDraw
Tangent(20,5,Pic0B)
Tangent(52,5,Pic0C)
DispGraph^^r
Text(58,58,"by Toctave"
Repeat getKey
End
ClrDraw^^r^^r
Return


.Subroutine to easily create rectangles for the scores and game table itself, r1 to r4 is the same as for the Rect( command, r5 is used to tell how the corners will look
Lbl RECT
HLine({r2},{r1}-{r5},{r1}+{r3}+{r5}
HLine({r2}+{r4},{r1}-{r5},{r1}+{r3}+{r5}
VLine({r1},{r2}-{r5},{r2}+{r4}+{r5}
VLine({r1}+{r3},{r2}-{r5},{r2}+{r4}+{r5}
Return

.No need to explain here I think
Lbl D
Tangent(32,3,Pic0A
For(I,0,15)
L1+I->P
I^4*9+31->F
I/4*9+21->G
If {P}=1
Pt-On(F,G,Pic1)
ElseIf {P}=2
Pt-On(F,G,Pic2)
ElseIf {P}=3
Pt-On(F,G,Pic3)
ElseIf {P}=4
Pt-On(F,G,Pic4)
ElseIf {P}=5
Pt-On(F,G,Pic5)
ElseIf {P}=6
Pt-On(F,G,Pic6)
ElseIf {P}=7
Pt-On(F,G,Pic7)
ElseIf {P}=8
Pt-On(F,G,Pic8)
ElseIf {P}=9
Pt-On(F,G,Pic9)
ElseIf {P}=10
Pt-On(F,G,Pic10)
ElseIf {P}=11
Pt-On(F,G,Pic11)
ElseIf {P}=12
Pt-On(F,G,Pic12)
Else
Pt-On(F,G,Pic0)^^r
End
End
RECT(29,19,38,38,1
RECT(70,21,24,14,~1
RECT(70,38,24,14,~1
DispGraphClrDraw^^r

Text(72,22,"Score:"
Text(73,28,S>Dec
Text(75,39,"Best:"
Text(73,45,{Q+18}^^r>Dec


About the N variable :
The problem was that when going Left for example, with 3 as a limit, the program was doing this :
[8,4,4,0]=>[0,0,0,16]
with steps : [8,4,4,0]=>[8,4,0,4]=>[8,0,0,8]=>[0,0,0,16]
Now, it does the following :
[8,4,4,0]=>[0,0,8,8]
[8,4,4,0]=>[8,4,0,4]=>[8,0,0,8]=>Set the limit to the third cell (targetted cell was fourth, limit is target-1) => [0,0,8,8] (the 8 stopped at the third cell because the limit was reached


And here's a gif, as you can see the Text is laggy and causes the grayscale to look bad, and I have no idea how to fix this, if anyone could help that could be great.

Here's a gif without the text to show how fast it should be :



Controls :
Arrows to swipe in a direction
2nd to show the help screen
mode to reset the game
Clear to quit

Pages: 1 [2]