Current Code:


Code:

.MAZE
#ExprOff
[2424FF2424FF2424]->Pic000
[0000000000001818]->Pic001
[0000000000000000]->Pic002
[0000000000000000]->Pic003
[000000000000000000000000]->GDB0
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000000000000000000000000]
DiagnosticOff
[3C409EA2A29E423C]->Pic100
0->X->Y
Repeat getKey(15)^^r
If getKey(4)?Y>0
Y--
ElseIf getKey(1)?Y<7
Y++
ElseIf getKey(2)?X>0
X--
ElseIf getKey(3)?X<11
X++
End
Lbl DP
ClrDraw
For(B,0,7)
For(A,0,11)
Pt-Off(A*8,B*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic1)
DispGraph
End
Return
At GinDiamond's request, here is my suggested implementation of very basic collision detection with the tilemap:



Code:

.MAZE
prgmFLOOR1
DiagnosticOff
[3C409EA2A29E423C]->Pic1
3->X->Y
Repeat getKey(15)
If getKey(4)?Get(X,Y-1)
Y--
ElseIf getKey(1)?Get(X,Y+1)
Y++
ElseIf getKey(2)?Get(X-1,Y)
X--
ElseIf getKey(3)?Get(X+1,Y)
X++
End
Lbl DP
For(B,0,7)
For(A,0,11)
Pt-Off(A*8,B*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic1)
DispGraph
End
Return
Lbl Get
Return {r2*12+r1+GDB0}
I have a problem with this code:

PROGRAM MAZESRC

Code:
.MAZE
prgmFLOOR
DiagnosticOff
[3C409EA2A29E423C]->Pic100
3->X->Y
Repeat getKey(15)
If getKey(4)?Get(X,Y-1)
Y--
ElseIf getKey(1)?Get(X,Y+1)
Y++
ElseIf getKey(2)?Get(X-1,Y)
X--
ElseIf getKey(3)?Get(X+1,Y)
X++
End
Lbl DP
For(B,0,7)
For(A,0,11)
Pt-Off(A*8,B*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic100)
DispGraph
End
Return
Lbl Get
Return {r2*12+r1+GDB0}


PROGRAM FLOOR

Code:
.FLOOR
[2424FF2424FF2424]->Pic000
[0000000000001818]->Pic001
[0000000000000000]->Pic002
[0000000000000000]->Pic003
[000000000000000000000000]->GDB0
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000101010101010101010100]
[000000000000000000000000]


I get an error when I try to compile this game when it says ERR: WRONG # OF ARGS. The scroller takes me to the

Return {r2*12+r1+GDB0}

with the cursor at the "r" of r2.

Whats the problem here? (Axe version 1.2.0, compiling for Axe Fusion)
You can't actually give Return an argument parameter - only an If or !If conditional (and the Return doesn't even have a space anyway). The correct usage of Return for that purpose is:

Code:
{r2*12+r1+GDB0}
Return

This will put the value of the tilemap at that spot into HL (the "running total" or "Ans" value that Axe uses and virtually every statement - not just every line) effects.

But to answer your particular problem, r1 and r2 are the Polar functions (Vars menu -> Y-VARS -> 3: Polar), not an "r" followed by a 2.
Compynerd255 wrote:
You can't actually give Return an argument parameter


Pretty sure you can. Wink

But I have no idea why he would be getting that error there...
Runer112 wrote:
Compynerd255 wrote:
You can't actually give Return an argument parameter


Pretty sure you can. Wink

But I have no idea why he would be getting that error there...

I did not know that about Returns. If you can use them like that, I'll buy that.

As for the error, as I stated in the post, I think that he might be using the wrong r (instead of using the Polar variables, he's using a lowercase r or superscript r).
Thanks!

It was just that the r2 and r1 weren't polar vars.

So, how does the collision detection work?
Current code:

PROGRAM MAZESRC


Code:
.MAZE
prgmFLOOR1
DiagnosticOff
[3C409EA2A29E423C]->Pic100
1->X->Y
Repeat getKey(15)
If getKey(4)?Get(X,Y-1)
Y--
ElseIf getKey(1)?Get(X,Y+1)
Y++
ElseIf getKey(2)?Get(X-1,Y)
X--
ElseIf getKey(3)?Get(X+1,Y)
X++
ElseIf getKey(48) and getKey(14)?Get(X,Y)=2
1->X->Y
End
Lbl DP
For(B,0,7)
For(A,0,11)
Pt-Off(A*8,B*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic100)
DispGraph
End
Return
Lbl Get
Return {r2*12+r1+GDB0}


PROGRAM FLOOR1


Code:
[00247E24247E2400]->Pic000
[0000000000001818]->Pic001
[C0300C03030C30C0]->Pic002
[000000000000000000000000]->GDB0
[000101010101010101010100]
[000100010100000000000100]
[000101000100010101000100]
[000101000100020101010100]
[000100010100000000000100]
[000101010101010101010100]
[000000000000000000000000]
I've been fooling around with a scrolling map.

How the heck do I do that?
GinDiamond wrote:
I've been fooling around with a scrolling map.

How the heck do I do that?

It's elementary, really. I use it all the time in my games:
1. Define two extra variables (I'd recommend U and V) for the top left corner of the camera space.
2. Before you draw, use the position of the player to determine where the camera should be, typically subtracting half the screen width and height (which would be 48 and 36, respectively, on a calculator, although if you're centering an 8x8 sprite, you'd want to subtract 44 and 32).
3. Set up your For() loops that draw your tiles so that they only go in the range of tiles that will appear on your screen (e.g. go from 0 to 12 and 0 to 8 for 8x8 tiles)
4. Whenever you draw anything on the screen, subtract U and V from its X and Y in world space to get its screen space.

Does that help?
*Bump*

I've decided to resurrect this project because there seems to be a lack of ASCII Ti 84+ roguelike games out there.

My next step is to introduce map scrolling.

Here is the main code (not the FLOOR1 map:)


Code:

.ROGUE
prgmFLOOR1
DiagnosticOff
[3C409EA2A29E423C]->Pic100
1->X->Y
Repeat getKey(15)
If getKey(4)?TCh(X,Y-1)
Y--
ElseIf getKey(1)?TCh(X,Y+1)
Y++
ElseIf getKey(2)?TCh(X-1,Y)
X--
ElseIf getKey(3)?TCh(X+1,Y)
X++
ElseIf getKey(48) and getKey(14)?TCh(X,Y)=2
1->X->Y
End
Lbl DP
..Scrolling Map?
If X>8 or Y>12
X-8->U
Y-12->V
End
If X<8 or Y<12
0->U->V
X->U
Y->V
End
For(B,U,U+7)
For(A,V,V+11)
Pt-Off(A*8,B*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic100)
DispGraph
End
Return
Lbl TCh
Return {[r2]*12+[r1]+GDB0}


I have changed the Get label to TCh for Tile Check, because Get( is recognized as a token by Axe.

I have tried to introduce scrolling by having the game see if your X position is more than 6 and Y position is more than 10, and my idea here was to then move the map so you would then be in the upper left corner relative to the map.

What I want is for the game to scroll the map left/right/up/down 1 tile for every 1 tile you move IF you are 1 tile from the edge of the screen.

Like:

Normal screen (you move normally, the screen won't scroll if you are not 1 tile away from any edge:)

Code:

########
#........
#........
#........
#....@...
#........
#........
#........
########


Now if I were in this position and pressed the RIGHT arrow key, the map should scroll with you like so:

Before RIGHT key:


Code:

########
#........
#........
#........
#........
#........
#......@.
#........
########


After:


Code:

########
.........
........
.........
.........
.........
.......@.
.........
########


Does anyone have some pointers (no pun intended) on how to take on this task?
Okay, the code is so far as follows:


Code:

.ROGUE A roguelike
prgmFLOOR1
DiagnosticOff
[3C409EA2A29E423C]->Pic100
1->X->Y
Repeat getKey(15)
If getKey(4)?TCh(X,Y-1)
Y--
ElseIf getKey(1)?TCh(X,Y+1)
Y++
ElseIf getKey(2)?TCh(X-1,Y)
X--
ElseIf getKey(3)?TCh(X+1,Y)
X++
ElseIf getKey(48) and getKey(14)?TCh(X,Y)=2
1->X->Y
End
Lbl DP
For(B,0,7)
For(A,0,11)
Pt-Off(A-X*8,B-Y*8,{B*12+A+GDB0}*8+Pic000)
End
End
Pt-Off(X*8,Y*8,Pic100)
DispGraph
End
Return
Lbl TCh
Return {[r2]*12+[r1]+GDB0}
Return


When I change:

Code:

Pt-Off(A-X*8,B-Y*8

to

Code:

Pt-Off(A*8,B*8


everything works fine and dandy like it should. However, when I put back in the -X and -Y, the entire screen doesn't render, and the collision map is WAY off.

Questions:
1. How do I show all of the map I want to render?
2. How can I make this work with a bigger map?
3. How can I make it so the user can't spam the arrow keys?

Thanks!

**EDIT**

Pastebin:

http://pastebin.com/6V8zB3aj
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement