I think I get as far as making the maps, but displaying them seems difficult. (On another note, I am currently working with ARG 4 and done with ARG 1-3. ARG 4 and 5 are left to do of this series, then I'm done with ARG entirely. After that, I will continue to learn about homescreen "graphical" games.) Cool
adamac15 wrote:
I think I get as far as making the maps, but displaying them seems difficult. (On another note, I am currently working with ARG 4 and done with ARG 1-3. ARG 4 and 5 are left to do of this series, then I'm done with ARG entirely. After that, I will continue to learn about homescreen "graphical" games.) Cool
Displaying them is quite straightforward. I think you should start with a map that is exactly one screenful, ie, 16x8 characters, a 128-character string, with two simple For() loops. Then you can move on to trying to understand bigger maps and scrolling around them.
I read the whole tutorial mentioned by souvik1997, and I don't understand any of it.
adamac15 wrote:
I read the whole tutorial mentioned by souvik1997, and I don't understand any of it.
Can you start somewhere with your non-understanding? I'd imagine that the problem is trying to read it all at once without trying any of it, instead of learning one concept at a time and coding with each concept to cement it into your head. Is it the loops? The string manipulation? The getkey? What's throwing you?
The coding to display the map.
adamac15 wrote:
The coding to display the map.
What about a simple 8x16 map, two nested loops, with an output and a sub()? Would that make sense; should I provide a little code chunk to show what I'm talking about?
I think a code chunk would probably help. (sorry if this causes an inconvience)
adamac15 wrote:
I think a code chunk would probably help. (sorry if this causes an inconvience)
None whatsoever! The simple but slightly less optimal code chunk for a single-screen map might be:


Code:
:"XXXXXXXXXXXXXXXXX              XX              XX              XX              XX              XX              XXXXXXXXXXXXXXXXX->Str1 //a simple rectangle map
:For(B,1,8 //Y coordinates
:For(A,1,16 //X coordinates
:Output(B,A,sub(Str1,16(B-1)+A,1 //grab the (B,A)th character from Str1
:End:End


You can also do it in 8 sets of 16 characters to save the inner loop:



Code:
:"XXXXXXXXXXXXXXXXX              XX              XX              XX              XX              XX              XXXXXXXXXXXXXXXXX->Str1 //a simple rectangle map
:For(B,1,8 //Y coordinates
:Output(B,1,sub(Str1,16B-15,16
:End:End

Code:
:"XXXXXXXXXXXXXXXXX              XX              XX              XX              XX              XX              XXXXXXXXXXXXXXXXX->Str1 //a simple rectangle map
:For(B,1,8 //Y coordinates
:For(A,1,16 //X coordinates
:Output(B,A,sub(Str1,16(B-1)+A,1 //grab the (B,A)th character from Str1
:End:End


I put this one in my calc (as an example), and it says ERR: INVALID DIM.
Did you make sure that Str1 has at least 128 characters in it? Even if it's 128 random characters, you'll see how it maps from the string to the screen.
KermMartian wrote:
Did you make sure that Str1 has at least 128 characters in it? Even if it's 128 random characters, you'll see how it maps from the string to the screen.
I used Str9 (Str1 was used already) and it has 61 now.
Notice that I typed 128 characters. If you do the math on the loop, the highest value it can reach is the bottom-right corner of the screen, where B=8 and A=16. 16(B-1)+A = 16(8-7)+16 = 128.
Oh ok, i get it. But the thing is i got the string to 128 but it still comes up ERR: INVALID DIM
I suggest storing coordinates of each thing, rather than the character for each position. This would save on space.


Code:
:For(X,2,dim(L1),2
:Output(L1(X-1),L1(X),"X
:End
Shkaboinka: Lists elements are 9 bytes each, so that's 18 bytes per item. A 128-character string is 128 bytes. Therefore, that's only worth it for maps with fewer than *eight* non-empty positions in the entire screen.
KermMartian wrote:
Shkaboinka: Lists elements are 9 bytes each, so that's 18 bytes per item. A 128-character string is 128 bytes. Therefore, that's only worth it for maps with fewer than *eight* non-empty positions in the entire screen.
Ok, so what do I do then?
Are you sure that you copied out the code properly? If you did, and it's still not working, I'm not sure what the problem is. I assume the Invalid Dim is on the sub() statement?
KermMartian wrote:
Are you sure that you copied out the code properly? If you did, and it's still not working, I'm not sure what the problem is. I assume the Invalid Dim is on the sub() statement?
I think I did, but I'm not sure. I know I copied the code after the map right, so I don't know. And it does go to the sub() statement.

Progress on ARG series:

ARG 1- Finished
ARG 2- Finished
ARG 3- Finished
ARG 4- Finished
ARG 5- Current Work (last of the ARG series)
Here is what I did to display my maps in Dungeon.

Code:

;I usually store my map into a String.
"XXXXXXXXXXXXXXXXX              XX              XX              XX              XX              :XX              XXXXXXXXXXXXXXXXX->Str1 //a simple rectangle map
:For(Y,1,8       ;increases Y after X line is done
:For(X,1,16     ; 16 columns
:Output(Y,X,sub(Str1,(X*Y),1       ;gets the right character
:End
:End
;I think this should work if it doesn't try this
:"XXXXXXXXXXXXXXXXX              XX              XX              XX              XX              XX              XXXXXXXXXXXXXXXXX->Str1 //a simple rectangle map
:For(Y,1,8       ;Y coord
:Output(Y,1,sub(Str1,(Y*16),(Y*16)+16       ;should find the 16 characters needed , I do not know I haven't tried it.
:End

I would try to reset your calc, to see if some asm program has tampered with the sub( command, which is unlikely.
The first one worked. Thanks for clarifying that up for me.

Progress on ARG series:

ARG 1: Finished
ARG 2: Finished
ARG 3: Finished
ARG 4: Finished
ARG 5: Currently Working On (There might be an ARG 6, depends on how many bytes ARG 5 has)
  
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 4
» 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