CodeWalrus

Development => Calculators => Calculator News, Coding, Help & Talk => Topic started by: SiphonicSugar on September 22, 2015, 09:46:59 PM

Title: TI-Basic Collision Detection
Post by: SiphonicSugar on September 22, 2015, 09:46:59 PM
Okay, so I've had the idea of making an RPG for a while.  To keep things organized, I have a couple things written out (like a code flow chart and other stuff that I am to lazy to talk about).  So, I started a topic like this on Omnimaga but people seemed to forget about it, so I guess I'm moving over here.  Anyway, for the tile mapping that I am going to use in my RPG, I decided not to use matrices or lists, but store the maps in a string.  Well, everything works out correctly, and I can display a map on the screen (I'm to lazy to make it so you can change maps right now and I am still trying to find the easiest way to do it), but I do not have collision detection.  I want to be able to have the program do this:

Movement stuff
Test to see if your coordinates are not in a wall or something (I'm using "X" for walls right now)
If you are, then set your coordinates to what you had before you moved

But I have no idea how to do this, like test to see if there is an "X" where you want to move your player.
Title: Re: TI-Basic Collision Detection
Post by: c4ooo on September 22, 2015, 10:14:13 PM
Here is some quick code i wrote to accomplish this:

"()()()()()()()()
()::::::      ()
():    :      ()
():           ()
():           ()
():    :      ()
()::::::      ()
()()()()()()()()"->Str1
For(Y,1,8
Output(Y,1,sub(Str1,Y*16-15,16
End
5->X
5->Y
While 1
getKey->K
X+(K+26)-(K=24)->A
Y+(k=34)-(K=25)->B
If sub(Str1,B*16-16+A,1)=" "
Then
Output(Y,X," "
Output(B,A,"π"
A->X
B->Y
End
End

As you can probably tell, "π" is the player. The player can walk on top of anything that is a space.
Title: Re: TI-Basic Collision Detection
Post by: SiphonicSugar on September 22, 2015, 10:53:03 PM
Well, I find this very helpful!  :)
Title: Re: TI-Basic Collision Detection
Post by: Dream of Omnimaga on September 23, 2015, 02:06:15 AM
My advices:

1) Try to only use like 1-2 different tiles on which it's possible to walk into. That will speed up collision detection since you will only have to check 1 or 2 different characters.

2) If you run into a non-floor tile, make sure that your game exits the walking engine loop and processes the rest of the collision detection outside (eg if you encounter a NPC, door, treasure chest or boss). That might cause some lag when walking into walls, but at least walking on floors will be faster due to having fewer code inside the loop

3) Start small and backup often! RPGs can be overwhelming as first project and they get large fast. For example, see how few dungeons the first Illusiat games had.
Title: Re: TI-Basic Collision Detection
Post by: SiphonicSugar on September 23, 2015, 09:49:09 PM
What program or whatever do you recommend that I use for programming?  Because for some reason, I have this idea of programming on calculator, and I didn't know if that was a good idea or not...
Title: Re: TI-Basic Collision Detection
Post by: Unicorn on September 24, 2015, 02:34:14 AM
I suggest writing the bulk of th program in sourcecoder (it has cloud storage if you have a cemetech acount) so you can do it anywhere you have a computer, and also on-calc if you havesmall problems and a long car ride, or something like that. Make sure to keep each version the same though.
Title: Re: TI-Basic Collision Detection
Post by: Dream of Omnimaga on September 24, 2015, 04:44:45 AM
SourceCoder is what I use most of the time, but it requires an Internet connection. If you don't want to have to get on a website to use it, then TokenIDE might be better for you. TI-Connect CE has an editor as well but I don't know how good it is.


Also, backup often, very often, on multiple storage mediums.
Title: Re: TI-Basic Collision Detection
Post by: SiphonicSugar on September 24, 2015, 07:56:18 PM
Okay, thanks.  :D
Title: Re: TI-Basic Collision Detection
Post by: SJCubed on September 30, 2015, 12:12:58 AM
I use TokenIDE myself. Good luck with the RPG! I'm trying to finish what I tried to make 4-5 years ago right now >.<
Title: Re: TI-Basic Collision Detection
Post by: c4ooo on October 01, 2015, 06:56:35 PM
Actualy, you dont need to use for loops to render the map. You can render the map much faster with just Output(1,1,Str1)

Personally, i would recomend prgramming on the calc with a shell like doors or zstart. As long as every thing as archived, it should be easier.
Title: Re: TI-Basic Collision Detection
Post by: SiphonicSugar on October 01, 2015, 08:57:07 PM
I think that I am going to start using Doors instead of MirageOS.

Doors has a cursor!
I didn't want to use it at first because I did not like the CSE version.
Title: Re: TI-Basic Collision Detection
Post by: Dream of Omnimaga on October 03, 2015, 04:46:26 AM
I personally don't like the mouse, but I like DCS better than Mirage for a few things: First of all, it has instant Goto when exiting programs and going in the code, we can read archived program code (although DCSE8 implements it better) and unlike Mirage, folders won't get deleted after a RAM clear.


Also on the CSE you don't have much choice to use DCSE because it's the only shell available. :P
Quote from: c4ooo on October 01, 2015, 06:56:35 PM
Actualy, you dont need to use for loops to render the map. You can render the map much faster with just Output(1,1,Str1)

Personally, i would recomend prgramming on the calc with a shell like doors or zstart. As long as every thing as archived, it should be easier.
Indeed. You will be able to draw your map instantly that way.