Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASCII or Sprite movement

Status
Not open for further replies.

weekendwarrior7

Programmer
Feb 28, 2003
3
AU
I was wondering, if someone could explain to me how to make an ascii character move up and down as well as a sprite move up and down
 
ok, ummm, i'll show you how to make an "x" go up and down the screen

screen 0,,0,1
for y=1 to 50
cls
locate 1,y
print "x"
pcopy 0,1
x=0:do:x=x+1:loop until(x=10000)
next y
for y=50 to 1 step -1
cls
locate 1,y
print "x"
pcopy 0,1
x=0:do:x=x+1:loop until(x=10000)
next y

ok and to move a sprite up and down assume i have already used GET to get a sprite into an array sprite%().

screen 9,,0,1
for y=1 to 50
cls
put (50,y),sprite%()
pcopy 0,1
x=0:do:x=x+1:loop until(x=10000)
next y
for y=50 to 1 step -1
cls
put (50,y),sprite%()
pcopy 0,1
x=0:do:x=x+1:loop until(x=10000)
next y

 
also could you tell me how to make the sprite to move around with the keyboard
 
like this.


screen 13

x = 5 'x and y are the sprites coordinates
y = 8


locate x,y 'this tells the comp where to put our hero
print chr$(1) 'puts our hero, mr. smiley face in certain coordinates.
do 'here we start a loop that allows a person to keep on playing until he presses esc...
do
loop until inkey$ <> &quot;&quot; 'this loop waits until the player presses a key.
select case inkey$ 'here is where the comp figures out where to move our hero.
case is = chr$(0) + chr$(77) 'this is the code for an arrow key. don't know which...
x = x + 1
case is = chr$(0) + chr$(80) ' another arrow. don't know which.. so i'll guess.
y = y + 1
locate x,y
chr$(1)
loop until inkey$ = chr$(27) 'chr$(27) is the escape key.
end

here are all the arrow keys. you'll have to figure out which is which.

chr$(0) + chr$(77)
chr$(0) + chr$(72)
chr$(0) + chr$(80)
chr$(0) + chr$(75)

note that this is very basic. i never covered anything like collision or menu's. but i know a person that can help you quite a bit... Jocke the Beast! The master of Ascii games! here's a url of a website he goes to.


have fun! tell me when you finish!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top