This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
ryan644


Newbie


Joined: 01 Jul 2003
Posts: 4

Posted: 01 Jul 2003 03:36:35 pm    Post subject:

Okay I have a few questions.
How do I make a movable charector in a RPG?
Can I make it so its not a pixel (my own pic)?
When I make a map, draw it out in the graph how do I make it so you can't run through the lines/walls?
As you can tell im just starting my brain hurts Neutral
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 04:06:07 pm    Post subject:

ryan644 wrote:
Okay I have a few questions.
How do I make a movable charector in a RPG?
Can I make it so its not a pixel (my own pic)?
When I make a map, draw it out in the graph how do I make it so you can't run through the lines/walls?
As you can tell im just starting my brain hurts Neutral

Moveable and graphical character, not very good for AI and animations, they will slow down when the user moves much:

ClrDraw
AxesOff
1->Xmin
1->Ymin
95->Xmax
63->Ymax
47->A //x position of character
31->B //y pos of char
6->S
Repeat Q //until user presses clear
//draw character:
Line(A,B,A+6,B //arms
Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
Repeat K //wait for keypress
getKey->K
End //loop K
Text(63-B,A," " //6 spaces to erase character
A-S(K=24)+S(K=26->A //move character horizontally S pixels
B-S(K=34)+S(K=25->B //move character vertically S pixels
(K=45->Q //if user want's to quit
End //loop Q

Theory:
×set up
×loop1
×draw character
×loop2, until key is pressed
×get key pressed
×back to loop2
×erase character
×move character according to which key is pressed
×back to loop1

Good (well, better anyway, basic is just a bit slow for AI combined with graphics) for AI and animations but slower response for player:
ClrDraw
AxesOff
1->Xmin
1->Ymin
95->Xmax
63->Ymax
47->A //x position of character
31->B //y pos of char
6->S
Repeat Q //until user presses clear
getKey->K
If(K:Text(62-B,A," " //6 spaces to erase character
A-S(K=24)+S(K=26->A //move character horizontally S pixels
B-S(K=34)+S(K=25->B //move character vertically S pixels
//draw character:
Line(A,B,A+6,B [color=green]//arms

Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
(K=45->Q //if user want's to quit
End //loop Q

Theory:
×set up
×loop
×get key press
×if key is pressed, erase character
×move character according to key pressed
×draw character
×back to loop

Collision detection (don't walk through things):
Repeat Q
getKey->K
If(K:Text(62-B,A," " //6 spaces to erase character
//calculate new position
A-S(K=24)+S(K=26->C
B-S(K=34)+S(K=25->D
//check if place is free, using PxlTest(Y,X
0=PxlTest(62-D+.5S,C+.5S->Ø //only checks middle of new pos, so when you're drawing a wall you should make it S pixels wide or, if you want smaller walls, add more PxlTests
A+Ø(C-A->A //move character horizontaly if new position is free
B+Ø(D-B->B //move character vertically if new position is free
//draw character:
Line(A,B,A+6,B [color=green]//arms

Line(A+3,B,A+3,B-3 //body
Line(A+3,B-3,A,B-6 //leg
Line(A+3,B-3,A+6,B-6 //another leg
(K=45->Q //if user want's to quit
End //loop

Theory:
×set up
×loop
×get key pressed
×if key pressed, erase character
×calculate new position of character
×check if this new position is free with PxlTest(Ypixel,Xpixel
×if so, move character
×draw character
×back to loop


Last edited by Guest on 01 Jul 2003 06:28:32 pm; edited 1 time in total
Back to top
ryan644


Newbie


Joined: 01 Jul 2003
Posts: 4

Posted: 01 Jul 2003 04:09:13 pm    Post subject:

Thanks A LOT
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 04:13:02 pm    Post subject:

No, problem, I've got something this code memorized to the letter after all the times I've used it in never completed RPG's.

Last edited by Guest on 01 Jul 2003 06:28:49 pm; edited 1 time in total
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 01 Jul 2003 04:14:53 pm    Post subject:

this is the sprite i would use:
001100
010010
001100
111111
001100
010010
100001

so to place the character at A,B:

Code:
Line(A+2,B,A+3,B
Line(A+1,B-1,A+2,B-2
Line(A+4,B-1,A+3,B-2
Line(A,B-3,A+5,B-3
Line(A+2,B-4,A,B-6
Line(A+3,B-4,A+5,B-6


i have more code but i g2g. ill edit and put in the other code when i get back.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 04:23:00 pm    Post subject:

Which would require either a really really slow list, string or matrix routine or a fast ASM program.

Or you could mess around with the number in the Line( statements.

Here's the sprite i always use:
001100
111111
001100
010010
010010

Then I could add shoes like so:
001100
111111
001100
010010
110011

Or a hat like so:
000010
001110
111111
001100
111111
001100
010010
010010

Or a staff like so:
1001100
1111111
1001100
1010010
1010010

Or a robe like so:
001100
111111
001100
010010
111111

The neat thing is, they can all be combined, so I just have some extra line( or pt-on( statements after drawing that first sprite and it adds what the character has (a robe, hat, shoes, staff, etc.) This way the player can actually see the equipment (well, most of it anyway, you wouldn't be able to tell the difference between a staff of spellcasting and a staff of asskicking +6 though) of his/her character.


Last edited by Guest on 01 Jul 2003 04:32:18 pm; edited 1 time in total
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 01 Jul 2003 04:25:48 pm    Post subject:

i usually use text ( "=>" for a mouse)
really fast
Back to top
Jeffrey


Member


Joined: 12 Jun 2003
Posts: 212

Posted: 01 Jul 2003 04:46:28 pm    Post subject:

If you use a sprite and increase the number of pixels moved when you hit the keypad it adds the illusion of speed, but it is still slow.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 04:56:53 pm    Post subject:

Well, that's basic, slow.

The first piece of code that isn't very good for AI or animation runs pretty fast I think, I can remember it running pretty fast anyway.
Back to top
Jeffrey


Member


Joined: 12 Jun 2003
Posts: 212

Posted: 01 Jul 2003 05:05:47 pm    Post subject:

Yes. Also, if you want to have a copy of this code, or something similar to it, look at the Upbeat engine on ticalc.org under TI-83+ Games. Or do a search.

Here is a similar engine:

Crap911 engine

The enigne is called the Crap911 enigne (its an updated Upbeat engine), I didnt write it, but it is open source, so pick out the code.


Last edited by Guest on 01 Jul 2003 05:06:26 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 05:31:27 pm    Post subject:

Well, that engine isn't exactly good, why you ask, just look at all the labels. Labels are slow. (not bad or evil)
Also, note the use of different if then statements for each key.

Let's just say I find the name appropriate for the engine.

Edit: ok, also note the use of goto inside if then statements, if you run into walls too much the game will crash.


Last edited by Guest on 01 Jul 2003 05:35:53 pm; edited 1 time in total
Back to top
Jeffrey


Member


Joined: 12 Jun 2003
Posts: 212

Posted: 01 Jul 2003 05:37:51 pm    Post subject:

Lol, yes very inefficient.

However the newer Crap911 does not use labels for its right left up and down routines just something like:

If K=24
Then
Pxl-Test( A , B )->D
If D=1
Goto 1
B-2->B
End
Goto 1


Last edited by Guest on 01 Jul 2003 05:38:48 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 Jul 2003 05:47:22 pm    Post subject:

Repeat Q or Ø
getKey->K
If K:Pxl-Off(B,A
A+(K=26)-(K=24->C
B+(K=34)-(K=25->D
0=Pxl-Test(D,C->Ø
A+Ø(C-A->A
B+Ø(D-B->D
(K=45->Q
End
If Ø:Then //player hit a pixel
//check if building has to be loaded or maybe battle sequence
End

Note that in my first post I forgot to add 0= to "PxlTest(62-D+.5S,C+.5S" so that should look like "0=PxlTest(62-D+.5S,C+.5S" If you do not change this the player can only move through walls.

Arg, it's getting late I just jumped because I thought I saw a huge something crawling up to me but it was my cat. Neutral


Last edited by Guest on 01 Jul 2003 05:58:30 pm; edited 1 time in total
Back to top
JesusFreak
JesusFreak


Active Member


Joined: 17 Jun 2003
Posts: 537

Posted: 01 Jul 2003 09:17:59 pm    Post subject:

then how do you do one with out lbls ??
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 02 Jul 2003 06:18:04 am    Post subject:

That's exactly what this:

Quote:
Repeat Q or Ø
getKey->K
If K:Pxl-Off(B,A
A+(K=26)-(K=24->C
B+(K=34)-(K=25->D
0=Pxl-Test(D,C->Ø
A+Ø(C-A->A
B+Ø(D-B->D
(K=45->Q
End
If Ø:Then //player hit a pixel
//check if building has to be loaded or maybe battle sequence
End


is, but it only moves 1 pixel at a time. Though this can be easily changed by adding the number of pixels to move like so:

A+3((K=26)-(K=24->C
B+3((K=34)-(K=25->D
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement