Here's the beginnings of an ASCII platform game.
remstart
-------------------------------------------------------------------
program name: ASCII Adventures
-------------------------------------------------------------------
written by: OBese87
date: 4th August 2007
-------------------------------------------------------------------
comments:
-------------------------------------------------------------------
remend
`--------------
` SETUP
`--------------
set text font "arial"
set text size 25
hide mouse
gosub create_world
sync on : sync rate 30
`--------------
` MAIN PROGRAM
`--------------
DO
gosub Controls
gosub Screen
gosub Sums
gosub Display
LOOP
END
`--------------
` GOSUBS
`--------------
create_world:
DIM Lvl(500,3)
rem 0:type[0=ground 1=water(odd width) 2=platform(even width)], 1:base height, 2:motion height, 3:color
DIM Ter$(2)
Ter$(0)="="
Ter$(1)="~"
Ter$(2)="¬"
`set default values
for g = 0 to 500
if g <= 73 then Lvl(g,1)=300 else Lvl(g,1)=230+sin(g*3)*20
lvl(g,3) = rgb(255,255,255)
next g
for t = 0 to 500 step 2
lvl(t,3) = rgb(255,0,0)
next t
`add a hill
for hill = 20 to 40
lvl(hill,1) = 300 - sin((hill-20)*9)*20
next hill
`add some water
for water = 50 to 60
lvl(water,0)=1
lvl(water,1)=302
lvl(water,3)=rgb(0,0,160)
next water
`add a platform
for plat = 70 to 73
lvl(plat,0)=2
lvl(plat,1)=260
lvl(plat,3)=rgb(160,160,160)
next plat
RETURN
`---
Controls:
if rightkey()=1 and px-scroll>=0 then inc Px,1
if leftkey()=1 then dec Px,1
`jump
Toggle_State = onepress(57)
If Toggle_State = 1 and ground=1 then jump=10
RETURN
`---
Screen:
`screen scroll
if px-scroll>24 then inc scroll,1
if px-scroll<26 then dec scroll,1
`bind screen scroll
if scroll < 0 then scroll = 0
if scroll > 450 then scroll = 450
`bind player
if px<0 then px=0
if px>500 then px=500
if py>400 then px=0 : py=0
RETURN
`---
Sums:
`gravity
IF jump=0
if ground=0
if py<lvl(px,1)-20 or py>lvl(px,1)
inc py,15
else
if py<lvl(px,1) then ground=1
endif
else
if py>lvl(px,1)+5 then ground=0
if ground=1 then py=lvl(px,1)-17
endif
ELSE
dec py,jump
dec jump,1
ground=0
ENDIF
`get platform height
ph=wave(500,30,10,ph)
RETURN
`---
Display:
cls
print "Xpos: ";px
`*display world
For ter = 0+scroll to 50+scroll
ink lvl(ter,3),0
if lvl(ter,0)=1 then w=wave(ter,5,65,w)
if lvl(ter,0)=2 then lvl(ter,2)=lvl(500,2)
text (ter-scroll)*13, lvl(ter,1)+lvl(ter,2), ter$(lvl(ter,0))
Next ter
`display player
ink rgb(255,255,0),0
text (px-scroll)*13,py+lvl(px,2),"@"
sync
RETURN
`--------------
` FUNCTIONS
`--------------
FUNCTION wave(x,max,spd,h)
h = wrapvalue(h+spd)
Lvl(x,2) = sin(h)*max
ENDFUNCTION h
`---
FUNCTION onepress(key)
if keystate(key) > LastState : ` > trip switch : < release switch
ToggleState = 1
else
ToggleState = 0
endif
LastState = keystate(key) : `this variable will retain its value for the next call
ENDFUNCTION ToggleState
For some reason I had to put the gosub that declared the lvl() array before a function that used it, even though i call the gosub first!
Your signature has been erased by a mod because it was rubbish.