I'm starting to learn hybrid basic and I have a few questions that I can't find answers to:

How do you easily remove a sprite after it's drawn? I have a character sprite that I can move around and I do not know how to easily erase it when it moves. I have been able to do it with an If K statement, but how would I do it with UserVar variables. If I make with getkey and an If K it runs much slower than if I were to run it with uservar variable and the GetKeyArrows.

How would I create a top view map that has many sprites all together to make some sort of an arena? I don't understand how to make the map redraw, and how I can add in obstacle like things you can't just walk over. I'm guessing I probably want to use DrawMap, but the syntax for it doesn't really make sense.

Thanks in advance!
I apologize that I left this tab open with no response in my browser for so long!

1) Removing a sprite after it's drawn: pseudocode for a typical game that draws and erases a character is something like this:
Code:
Repeat (until game quit condition)
Draw map
Repeat (until map needs to be redrawn)
Draw character
Repeat K
getKey->K
End // End the Repeat K loop
Erase character
Handle arrow keys, and set some condition in the map needs to be redrawn. Also set some condition if the game is over, eg, if the user pressed [CLEAR].
End // End the (until map needs to be redrawn) loop
End // End the (until game quit condition) loop


2) What you're describing is called a tilemap, and xLIBC does indeed have the capabilities to handle tilemaps via DrawMap. It's up to you to interpret some data structure holding the identity of the object at each tile in the tilemap so that you know if the character can walk over it or not. The code would probably look like:

Code:
If K is an arrow key:Then
X->old_X:Y->old_Y
Update X and Y based on arrow key K
If tilemap(X,Y) cannot be walked on:Then
old_X->X:old_Y->Y // undo the move
End
End
Thanks a lot for your help, I really should have thanked you earlier...

Anyways, how do you make a tilemap to use with the drawmap function, and what would it look like? I don't understand really, just from the DCSE SDK.
Have you already taken a look at the xLIBC tutorial that tr1p1ea put together? I believe that it shows some of the basics of using the tilemap functions that might be very helpful to you here:
http://dcs.cemetech.net/index.php/XLIBC_Tutorial
Thanks! I remember seeing this before, just I couldn't find it. Thanks, I think this is what I'm looking for.
DWMelon wrote:
Thanks! I remember seeing this before, just I couldn't find it. Thanks, I think this is what I'm looking for.
Great! Do ask questions as you try to understand that tutorial, though, because a number of the xLIBC functions have arguments that even I find a little confusing. I'm hoping we'll be able to come up with a more in-depth tutorial for xLIBCE on the TI-84 Plus CE to help clarify some of the lessons that I think xLIBC programmers learned by inspecting existing code and games rather than from the documentation.
Well, I've read through the tutorial and it (kind of) makes sense, but I have one huge question:
How do you actually make a tilemap? Will I need a computer to make it and can I use TokenIDE if so?
Also, are there any games out there already that utilize a tilemap, so I can look at it for examples?
DWMelon wrote:
Well, I've read through the tutorial and it (kind of) makes sense, but I have one huge question:
How do you actually make a tilemap? Will I need a computer to make it and can I use TokenIDE if so?
Also, are there any games out there already that utilize a tilemap, so I can look at it for examples?

You should use indeed TokenIDE. The first you need is a spritesheet. Tools > Hex Sprite Editor > Color Sprites. There should you set the dimensions at 128x64 and the colors at "xLIBC". Create a nice spritesheet and save it as "xLIB tiles". Close the sprite editor, and open Tools > xLIBC Map Editor. Click on File > Add tiles, and select your spritesheet. Now you can create any map you want. Once you're ready, click File > Insert and Exit. In TokenIDE there are now a bunch of characters. That would be Str9 in your program.

For your program, to load the map, use something like this:

Code:
real(0,1,1
real(8,1,not(real(8,0
"my_name_of_spritesheet"
real(5,0,0
"that_bunch_of_characters"->Str9
real(3,0,(starting_x),(starting_y),(width_of_map, mostly 20),(string_holding_the_map, Str9),0,0,19,14,0


I hope this helps. If you have any questions, feel free to ask.
It helped a TON, I can't wait to try it! Thanks a lot Smile
  
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 1 of 1
» 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