hey everyone. i really like to program arcade games that do not deal with much movement besides advanced menus. on to the point though, im trying to understand about movement and i am having a difficult time with pretty much understanding everything such as how do i make it where my guy moving detects if he ran into a bad guy or just moving in general. So in summary i just need help with movement.

Well, you need to understand three things:

**Variables:**

You have several options such as matrices, lists, or real vars. you can use these to store coordinates or an object

**Output:**

This depends on whether you want to use text or if you want to draw on the graph. Here you have Line(,Pt-On(,pxl-On(, et cetera.

**getKey:**

This is usually crucial if you want the user to control movement, By doing something like getKey→A, you can detect what key is being pressed and make it perform some actions.

To keep things simple, you can use If statements to control what happens when a key is pressed, but as you get more advanced and your understanding of TI-BASIC increases, you can move on to more optimised code. Here is a simple example:

```
1→X
1→Y
Repeat A=45 ;If the keypress is 45, this means clear
Output(Y,X,"O ;This will display an O on the homescreen
Repeat A≠0 ;The code until the next end is repeated until A is not 0
getKey→A ;This stores the keypress to A
End ;This ends the Repeat block, so only getKey→A is repeated
Output(Y,X," ;There is a space after the ". This draws over the O
If A=26 ;26 is the key for the right arrow
X+1→X
If A=24 ;24 is right
X-1→X
If A=25 ;25 is up
Y-1→Y
If A=34 ;34 is down
Y+1→Y
If X=0 ;If you try to use Output( and the X or Y is 0, you will get an error!
16→X
If X=17 ;There are only 16 chars across, so you cannot Output( to column 17!
1→X
If Y=0
8→Y
If Y=9
1→Y
End
```

That code is horribly unoptimised, but it should be slightly easier to follow. As for hit detection, if the bad guy has his coordinates at (B,C), then you can simply compare (X,Y) to (B,C) using some simple math (like

**If B=X+1**meaning the bad guy is to the right).

I hope that helps a little!

Z80 Assembly>English>TI-BASIC>Python>French>C>0

thanks, i understand a good bit about basic commands such as those listed but more complicated movement things

```
:Zstandard
:104→Xmax
:72→Ymax
:Zinteger
:1→A
:1→B
:Repeat K=21
:getKey→K
:line(A,B,A,B,not(K
:min(94,max(0,A+sum(Δlist(K={24,26→A
:min(62,max(0,B+sum(Δlist(K={34,25→B
:End
```

im not sure how to interpret this in to my own words so that i understand what each command does and how to add other things to it to make it shoot or something alond those lines

I know what you mean :D I didn't figure those out until about 8 months ago and I have been making some pretty in depth BASIC programs for 3 or 4 years. If you understand boolean logic, if the statement is true, the result is 1, false is 0. So if K is 24, then doing K=24 returns 1 and K=26 returns 0. So bring that to a list and you can do K={24,26} to get a list {1,0}. So this line:

`:min(94,max(0,A+sum(Δlist(K={24,26→A`

Is now interpreted as:

`:min(94,max(0,A+sum(ΔList({1,0}→A`

ΔList( returns the difference between elements in a list. So in {1,0}, to get from 1 to 0 you add -1, so ΔList({1,0 returns {-1}. Take the sum of that list and you get -1. That brings the line of code down to:

`:min(94,max(0,A-1→A`

The max takes the max of 2 numbers, so if A-1 is less than 0, 0 is used instead (to prevent from going off the screen) and min takes the smaller of the two numbers.

I hope that helps!

Z80 Assembly>English>TI-BASIC>Python>French>C>0

Nice explanation Xeda.

`line(A,B,A,B,not(K`

Hm, that's a neat optimization. I think I'm going to use that in my code from now on. Anyway, this code is much easier to understand. Since the coordinate (A,B) is used twice, the Line( routine draws a line from (A,B) to (A,B). On the screen, this shows up as a single point. When K is not zero, the Not( function inverts it and returns a 0, which causes the Line( function to erase the point at (A,B). When K is zero (no buttons are pressed), the Not(K returns a 1 and the routine draws the point on the screen.

(∂²Ψ)/(∂x²) = -(2m(V(x)-E)Ψ/( ℏ²Ψ)

so where in this code would i put in a line to make the guy shoot and then if the bullet hits the guy it would disappear and say i win or something like that?

also thx for all the help so far =]

If you're doing a shooter game, then using Output(, or the home screen in general, is **very** limiting. Collision detecting is very easy on the graph screen, just use Pxl-Text and whatnot.

Which arcade games have you made so far?

Projects: BexIDE (hold), Hadean.NET, Legend of Zelda: Link to the Future

That would depend on how your code is arranged. Personally, I tend to put the necessary array look-ups after I update the position of the projectile because it saves an extra cycle in iterations.

(∂²Ψ)/(∂x²) = -(2m(V(x)-E)Ψ/( ℏ²Ψ)

i have made two games but they are kind of failures i make a game called click in which you hit your enter button as fast as you can untill the time runs out and there are diffrent modes and highscore menu and a place where you can type your initials if you get a new highscore. my second is a little more complicated as for logic its a game where you guess the calcs number but you can only enter the game 5 times before you get locked out unless you win certain modes than you get points and 1 subtracted from your total plays so that you can login and play more . but if you run out of plays then you have to reset your highscores and points so that you can play again and this also makes your number of plays go back to 0. (sorry puncuation is my enemy ) .

srry that i havent said anything in awhile i have been busy with schhol stuff so thats y. but could someone show me code of a guy that can move and shoot with hit detection on enemies still having trouble with this.

**thanks much everyone**

Just for organization, I moved this to the Programming Help / TI-83 Programming section.

how can i get to this srry have been busy

What do you mean by "how can I get to this?"

Z80 Assembly>English>TI-BASIC>Python>French>C>0

nvm i had a brain fart so i have been working on some of the stuff you guys have been tlking about and i am kinda stuck this is my code

```
:Zsquare
:25->A
:6->H
:1->B
:50->T
:90->S
:41->Z
:32->Y
:25->W
:text(1,1,"[5 spaces here]then minus sign 74x
:text(57,1,"[same thing as above]
:while 1
:getkey->theta [i know you can just leaves getkey as is and use ans]
:A-5(theta=25 and A>6)+5(theta=34 and A<50)->A [for moving]
:text(A+5,B,"[4 spaces]
:text(A-5,B,"[4spaces]
:text(A,B,">
:if theta=21
:text(A,B+5,"----------- [11 minuses]
:text(A,5,"[47 spaces]
:S-2(S>1)->S [AI movement]
:text(T,S,"<-
:text(W,S,"<-
:text(X,S,"<-
:text(Y,S,"<-
:text(Z,S,"<-
:if A=T or W or X or Y or Z
:p+1000->p
:end
```

i know this isnt the best code ever and i have question on how i can make ai come out seperatly also how to make a projetile shoot instead of a beam and how i can get it to clear it self also how to make he targets come out multuple time and how to make them disappear after they are shot

**TYVM**

the beam is basically due to a +1 or +sth in the horizontal coordinate…it is thus possible to make a bullet shoot by deleting the OLD shaded coordinate AFTER the new one appears

Hence, for example

:Lbl A

:text(X,Y,"-") \\assuming - is bullet

:text(X-1,Y," ") \\space as deleter \\assuming bullet shoots in X direction

\\YOU SHUD PUT THE DELETER AFTER the appearance of the new "bullet"…NOT BEFORE cos it is harder for the human eye to detect 2 pixels as compared to an empty space…this will impact the later part of the prog.when the prog. runs slightly slower due to lesser memory

:X+1->X

:goto A

u shud now see a bullet instead of a beam

Just a few things… Lbl/Goto loops are not exactly advisable; that's what Repeat, While, and For( are for. Also, to make it easier to read, try putting your code into the given code brackets.

```
[[code]]
insert the code here
[[/code]]
```

Projects: BexIDE (hold), Hadean.NET, Legend of Zelda: Link to the Future

so the problem i am having is the bullet will shoot but it will not show n e thing else and wen the bullet hits the other side i cant get it to disappear insted it give me a error becuse it goes off screen. i also still need help with the other thing. all help is very much appreciated =)

Could you post your code, or at least the movement part? If you did, it would be a lot easier for us to help you.

Projects: BexIDE (hold), Hadean.NET, Legend of Zelda: Link to the Future

```
:Clrdraw
:Zstandard
:30->A
:10->B
:While 1
:A->D
:B->E
:getkey->C
:A-5(C=25 and A>10)+5(C=34 and A<50)->A
:text(A,B,">
:text(A-5,B,"2 spaces
:text(A+5,B,"2 spaces
:If C=21
:Then
:Repeat E=90
:text(D,E,"-
:textD,E,"2 spaces
:E+1->E
:End:End
```

thats pretty much it i was wodering how to shoot and be able to move at the same time and also how to make bad guys come out seperatly and in alternating places. and how to make them disapear when they are hit

you can just note down the coordinate of the END of the window…n include an "if" OR "for" statement before displaying the bullet, such that if the bullet's coordinate is EQUAL TO the max coordinate…then do not continue diplaying the bullet, then RESET the coordinate of the next bullet

Detecting a hit on the enemy is given by an if test OR any other viable test…such that if bullet coordinate =enemy coordinate then a hit is score…I SUGGEST U USE VARIOUS LISTS TO DO COMPARISONS OF COORDINATES AND TO REGISTER HITS

It is difficult to move and hit at the same time…mainly because movement is given mostly by "getkey" and hit is detected by an IF (or any otehr viable) test of <bullet coordinate=enemy coordinate>…given that TI BASIC only allows one program to run at any one time…it is impossible to move and detect a hit at anyone time…ESPECIALLY IF YOUR PROGRAM IS LONG, what you wud see will be that there is a CONSIDERABLE LAG between u PRESSING THE BUTTON, MOVEMENT OF THE ENEMY and REGISTRATION OF THE HIT

HOWEVER, you can turn it to a strategy game, such that you plot the positions of your shooters at different times first, randomise movement of the enemy and then perform the simulation…without you pressing any button during runtime…then DO A FINAL REGISTRATION OF THE NUMBER OF HITS BETWEEN U AND THE ENEMY TO DECIDE WHO WINS, AI OR U