Thought i might add, this code is what i want to use for my player.
As I said the prob is I can't get it to work without the x,y of the mouse relative to the player position.
Rem Project: 180 degree shooting
Rem Created: Friday, September 14, 2012
Rem ***** Main Source File *****
SYNC ON:SYNC RATE 0:AUTOCAM OFF:`HIDE MOUSE
set display mode 640,480,32
MAKE OBJECT SPHERE 1,10
make object box 3,2.0,5.0,5.0
yrotate object 3,90
MAKE OBJECT BOX 2,30,50,30
MAKE MESH FROM OBJECT 1,2
DELETE OBJECT 2
ADD LIMB 1,1,1
DELETE MESH 1
OFFSET LIMB 1,1,0,45,0
hide limb 1,1
POSITION CAMERA 0,0,-200
POINT CAMERA 0,0,0
type bultype
bulnum as integer
bulposx# as float
bulposy# as float
bulang# as float
bulfired as integer
bulfirstpos as integer
endtype
global omx#
global omy#
global CA#
global oldca#
global bulletposx#
global bulletposy#
global bulletcount
global buldir
global maxbul=10
global ftime=timer()
global firetime
dim bul(maxbul) as bultype
DO
omX#=mX#
omY#=mY#
opX#=object position x(1)
opY#=object position y(1)
opZa#=object angle z(1)
lmX#=limb position x(1,1)
lmdirX#=limb direction x(1,1)
lmY#=limb position y(1,1)
lmdirY#=limb direction y(1,1)
lmangX#=limb angle Z(1,1)
mX#=(320-mousex())
mY#=(240-mousey())
bulletposX#=object position x(3)
bulletposY#=object position y(3)
nmx#=mx#*2.0
if nmx#>120 then nmx#=120
if nmx#<-120 then nmx#=-120
if my#<opy#-30.0 then my#=opy#-30.0
angtan#=(mx#/my#)
ang#=atan(angtan#)
zrotate object 1,ang#
if spacekey()=1 then move object left 1,0.1
firetime=((timer()-ftime)/100)
if firetime>1
if mouseclick()=1
ftime=timer()
for n=0 to maxbul
if bul(n).bulfired=0
bul(n).bulfired=1
bul(n).bulposx#=lmx#
bul(n).bulposy#=lmy#
bul(n).bulang#=ang#+90.0
inc bulletcount
bul=N+100
clone object bul,3
bul(n).bulnum=bul
position object bul,bul(n).bulposx#,bul(n).bulposy#,0
zrotate object bul,bul(n).bulang#
inc bulletcount
exit
endif
next n
endif
endif
if bulletcount>0
for n=0 to maxbul
if bul(n).bulfired=1
move object bul(n).bulnum,0.1
bulposx#=object position x(bul(n).bulnum)
bulposy#=object position y(bul(n).bulnum)
bul=bul(n).bulnum
if bulposx#>320
bul(n).bulfired=0
delete object bul
dec bulletcount
endif
if bulposx<-320
bul(n).bulfired=0
delete object bul
dec bulletcount
endif
if bulposy#>320
bul(n).bulfired=0
delete object bul
dec bulletcount
endif
if bulposy#<0
bul(n).bulfired=0
delete object bul
dec bulletcount
endif
endif
next n
endif
text 20,20,"Mouse X: "+str$(mx#)
text 20,40,"Mouse Y: "+str$(my#)
text 20,60,"Firetime: "+str$(firetime)
text 20,80,"Ftime: "+str$(ftime)
text 20,100,"Bulletcount: "+str$(Bulletcount)
text 20,120,"limbdirY#: "+str$(lmdirY#)
text 20,140,"Opx#: "+str$(opX#)
text 20,160,"lmangY#: "+str$(lmangX#)
text 20,180,"ang#: "+str$(ang#)
SYNC
LOOP
Here is the game code sorry i'm new to programming and so its messy.
Didn't think i'd explained myself properly, probably still haven't
Rem Project: My Platformer
Rem Created: Monday, August 06, 2012
Rem ***** Main Source File *****
`----------------
`Types
`----------------
type Maptype
block as integer
id as integer
marker$ as string
state as byte
endtype
type Bullettype
bulletfired as integer
bulletx# as float
bullety# as float
bulletdir as integer
bulletang# as float
endtype
type Charactertype
X# as float
Y# as float
oldX# as float
oldY# as float
xs# as float
ys# as float
chardir as integer
chardirvert
charstnd as integer
charfc as integer
jump as integer
id as integer
health as integer
lives as integer
dedfrm as integer
dedflg as integer
deadanimcount as integer
enem as integer
jtime as integer
ftime as integer
jumpcounter as integer
firecounter as integer
bfir as integer
sxtimepls as integer
sxtimemin as integer
saucermv as integer
imgnum as integer
frame as integer
charanimcount as integer
chright as integer
ochright as integer
endtype
`-----------------
`Global variables
`-----------------
`Map
global map_x=50
global map_y=25
`Block/pickups
global block$=" *oE^"
global jewel_count
global jewel_score
global hy
global spc
global game_restart
global maxbullets
global plbulletcount
global enbulletcount
global bulletcount
global bx
`Player
global retx
global rety
global retx#
global rety#
global Game_end
global time
global seconds
global minutes
global finalt$
global player_name$
global oplayer_name$
global seconds$
global minutes$
global player_lives
global jumpcounter
global jtime
global ftime
global endir
global animcount
global mx#
global my#
global opx#
global opy#
global camerax#
global cameray#
maxbullets=10
`-----------------
`Arrays
`-----------------
dim map(map_x,map_y) as Maptype
dim char_col(2,2)
dim high_score(11)
dim final_time$(11)
dim player_Names$(11)
dim Enter_name$(10)
dim Chars(5) as charactertype
Dim bullets(5,MaxBullets) as bullettype
`for n=4 to 5
`chars(n).health=20
`next n
chars(0).lives=5
hy=200
jewel_count=0
jewel_score=0
game_restart=0
jtime=timer()
ftime=timer()
time=timer()
player_lives=5
animcount=4
deadanimcount=16
`----------------
`Screen set up
`----------------
Set display mode 1280,1024,32
sync on
sync rate 60
autocam off
`Camera
global CameraAngleY#
global CameraAngleX#
CameraAngleY#=camera angle y()
CameraAngleX#=camera angle x()
global x#
global y#
global z#
x#=35.0*5.0
y#=0.0*5.0
z#=-30.0*5.0
`Colours
global blue as dword
global light_blue as dword
global red as dword
blue=rgb(0,0,200)
light_blue=rgb(0,0,250)
red=rgb(200,100,0)
`-----------------
`Load/Create Files/Object
`-----------------
`Images
load image "desert mountains.png",11
load image "metal_plates.bmp",12
Load image "SpaceBritLFace1632.png",1
load image "SpaceBritLWalk1632.png",2
load image "SpaceBritRFace1632.png",3
load image "SpaceBritRWalk1632.png",4
`-----------------
`Camera/Background/Fog set up
`-----------------
`Camera
set camera range 20.0,1000.0
`Backdrop
backdrop on
color backdrop rgb(125,125,240)
`Fog
fog on
fog distance 1000
fog color rgb(125,125,240)
`------------------
`Backdrop plains
`------------------
for n=0 to 4
make object plain n+20,146*7,87*5
position object n+20,map_x*2.5,n*50.0-rnd(32),300+(n*50)
texture object n+20,11
scroll object texture n+20,rnd(100)/100.0,0.0
set object transparency n+20,2
set object texture n+20,0,0
set object fog n+20,1
next n
`------------------
`Objects
`------------------
make object cube 31,5.0:hide object 31
make object cube 34,5.0:hide object 34
load object "jewel.x",32: hide object 32
`------------------
`Player/Bullets/Enemies
`------------------
`player
make object plain 50,4.0,9.0
texture object 50,3
set object transparency 50,4
`Mouse shooting
MAKE OBJECT SPHERE 1,5
make object box 3,2.0,5.0,5.0
yrotate object 3,90
MAKE OBJECT BOX 2,5,5,5
MAKE MESH FROM OBJECT 1,2
DELETE OBJECT 2
ADD LIMB 1,1,1
DELETE MESH 1
OFFSET LIMB 1,1,0,5,0
`hide limb 1,1
`Bullets
make object plain 40,2.0,0.5 : hide object 40
`Enemies
make object plain 51,4.0,9.0
texture object 51,1
set object transparency 51,4
make object plain 52,4.0,4.0
`texture object 52,1
`set object transparency 51,4
`------------------
gosub Main_Menu
`---------------------------------------------------------
`--------------------------------------------------------
`MAIN LOOP
`---------------------------------------------------------
`---------------------------------------------------------
DO
ink rgb(255,255,255),0
text 20,280,"Info: "
text 20,300,"FPS: "+str$(screen fps())
text 20,320,"PL: "+str$(plbulletcount)
text 20,340,"EN: "+str$(enbulletcount)
text 20,360,"Bullets(0,2).bulletfired: "+str$(bullets(0,2).bulletfired)
text 20,380,"Bullets(0,3).bulletfired: "+str$(bullets(0,3).bulletfired)
text 20,400,"Mx#: "+str$(mx#)
text 20,420,"My#: "+str$(my#)
text 20,440,"PlX Map: "+str$(chars(0).x#)
text 20,460,"PlY Map: "+str$(chars(0).y#)
text 20,480,"OpX#: "+str$(opx#)
text 20,500,"OpY#: "+str$(opy#)
camerax#=camera position x()
cameray#=camera position y()
gosub Draw_Box
gosub Game_Timer
gosub Player_camera
gosub Player_Main
gosub Enemy_movement
`gosub firing
gosub Char_anim
gosub Pickup
gosub Info
gosub spike_col
gosub end_game
sync
loop
`-----------------------------------------------------------
`-------------------------------------------------------------
`SUB ROUTINES
`------------------------------------------------------------
`-------------------------------------------------------------
Main_Menu:
gosub Name
repeat
cls
Center text 640,510,"Hello, "+player_name$
center text 640,530,"Collect all the jewels and reach the end zone. Enjoy!"
Center text 640,550,"Press Space Key"
sync
until spacekey()=1
gosub init
return
`----------------
`----------------
Name:
Tc=1 : Ac=1 : dc=10 : dn=0 : ax=20
while scancode()<>28
cls
ink rgb(250,100,0),0
Center text (1280/2),(1024/2),"Please Enter Your Name"
center text (1280/2),(1024/2)+40,player_name$
if player_name$=""
player_name$=enter_name$(1)
endif
for n=2 to 10
if len(player_name$)=n-1
player_name$=player_name$+enter_name$(n)
endif
next n
if scancode()=14
repeat
nv$=enter_name$(dc)
if nv$<>""
enter_name$(dc)=""
player_name$=""
dn=1
endif
dec dc
if dc<0 then dc=0
until dn=1
tc=dc
dn=0
dc=10
endif
if inkey$()<>""
repeat
while enter_name$(TC)=""
entnme$=inkey$()
enter_name$(TC)=entnme$
endwhile
until inkey$()=""
endif
if enter_name$(tc)<>""
inc tc
if tc>10 then tc=10
if tc<0 then tc=0
endif
sync
endwhile
return
`----------------
`----------------
Init:
`Variable set up
jewel_score=0
jewel_count=0
seconds=0
minutes=0
time=timer()
spc=0
chars(0).health=100
for n=0 to 5
chars(n).charfc=1
chars(n).id=0
chars(n).imgnum=3
chars(n).ftime=ftime
next n
for n=1 to 5
chars(n).jtime=jtime
chars(n).deadanimcount=16
chars(n).lives=1
chars(n).health=40
chars(n).dedflg=0
chars(n).dedfrm=0
next n
for n=4 to 5
chars(n).saucermv=0
next n
if game_restart=1 then chars(0).lives=5
game_restart=0
gosub level
gosub build_map
return
`----------------
`----------------
level:
` 000000000011111111112222222222333
` ## 012345678901234567890123456789012
map_set(00,"EEEEEEEEEEEEEEEEEEEEEEE ")
map_set(01,"************************************* **^^^*")
map_set(02,"* ******")
map_set(03,"* ** *")
map_set(04,"* ooo ** *")
map_set(05,"* ** *")
map_set(06,"* **oo *")
map_set(07,"* *^^^* ** oo *")
map_set(08,"* ***** ******* *")
map_set(09,"*ooooo ooo** *")
map_set(10,"******* ooo** ooo*")
map_set(11,"* ooo** oooo*")
map_set(12,"* ********* ******")
map_set(13,"* ooo ooo ***** *")
map_set(14,"* *********^^^^^^** ooo *")
map_set(15,"* *^^^^^^** ooo *")
map_set(16,"* *^^^^^^^^^* ooo *^^^* *")
map_set(17,"* ************************** *")
map_set(18,"*^^^^^** *")
map_set(19,"*********** *")
map_set(20,"* ooo ooooo *")
map_set(21,"* Z ******* **********")
map_set(22,"* *")
map_set(23,"* ooooo oooo *")
map_set(24,"* S *****^^^^^^^^^^**************^^^^^^^^^^^*")
map_set(25,"**************************************************")
return
`----------------
`----------------
build_map:
`For loop
for y=0 to map_y
for x=0 to map_x
`Qube def
qube=((y*(map_x+1))+x)+1000
`Delete previous level
if object exist(qube)=1 then delete object qube
`Set block cords
xx#=(x*5.0)+2.5
yy#=(y*5.0)
zz#=0.0
`Check for standard block and create
if map(x,y).block=1
map(x,y).id=qube
clone object qube,31
scale object qube,100,100,200
texture object qube,12
position object qube,xx#,yy#,zz#
endif
`Check for pickup and create
if map(x,y).block=2
map(x,y).id=qube
map(x,y).state=0
inc jewel_count
clone object qube,32
r=rnd(255):g=rnd(255):b=rnd(255)
color object qube,rgb(r,g,b)
position object qube,xx#,yy#,zz#
endif
if map(x,y).block=3
map(x,y).id=qube
endif
if map(x,y).block=4
map(x,y).id=qube
clone object qube,31
scale object qube,100,100,100
color object qube,rgb(255,0,0)
position object qube,xx#,yy#,zz#
endif
next x
next y
return
`----------------
`----------------
Draw_Box:
ink blue,blue
box 20,20,260,180
ink light_blue,light_blue
box 40,40,240,160
return
`----------------
`----------------
Game_Timer:
seconds=((timer()-time)/1000)
if seconds>=60
inc minutes
seconds=0
time=timer()
endif
seconds$=str$(seconds)
minutes$=str$(minutes)
if minutes<10 then minutes$="0"+minutes$
if seconds<10 then seconds$="0"+seconds$
return
`-----------------
`-----------------
Player_camera:
if abs(camy#-chars(0).y#)>20.0
if camy#>chars(0).y# then dec camy#,1.0 : if camy#<chars(0).y# then camy#=chars(0).y#
if camy#<chars(0).y# then inc camy#,1.0 : if camy#>chars(0).y# then camy#=chars(0).y#
endif
if abs(camx#-plx#)>20.0
if camx#>chars(0).x# then dec camx#,1.0 : if camx#<chars(0).x# then camx#=chars(0).x#
if camx#<chars(0).x# then inc camx#,1.0 : if camx#>chars(0).x# then camx#=chars(0).x#
endif
if camy#<64 then camy#=64
if camx#>400 then camy#=400
if camx#<64 then camx#=64
if camx#>400 then camx#=400
position light 0,camx#,camy#+200.0,-153.0
position camera camx#,camy#,-110.0
rotate camera 0,0,0
`point camera opx#,opy#,0
return
`----------------
`----------------
Player_main:
chars(0).oldx#=chars(0).x#
chars(0).oldy#=chars(0).y#
chars(0).charstnd=0
opX#=object position x(1)
opY#=object position y(1)
`mx#=(640-mousex())
`mY#=(512-mousey())
mx#=mousex()
mY#=mousey()
Mmovex#=mousemovex()
Mmovey#=mousemovey()
lmX#=limb position x(1,1)
lmY#=limb position y(1,1)
nmx#=mx#`*2.0
`if nmx#>120 then nmx#=120
`if nmx#<-120 then nmx#=-120
`if my#<opy#-30.0 then my#=opy#-30.0
angtan#=(camerax#/cameray#)
ang#=atan(angtan#)
zrotate object 1,ang#
chars(0).firecounter=((timer()-chars(0).ftime)/100)
if spacekey()=1 and chars(0).firecounter=>2 then gosub Player_Add_Bullet
if plbulletcount>0 then gosub player_move_bullet
`Movement
chars(0).chardir=0
if leftkey()=1 then chars(0).chardir=-1 : chars(0).charfc=-1
if rightkey()=1 then chars(0).chardir=1 : chars(0).charfc=1
if chars(0).chardir=-1 then dec chars(0).xs#,0.4 : chars(0).charstnd=-1
if chars(0).chardir=1 then inc chars(0).xs#,0.4 : chars(0).charstnd=1
if chars(0).chardir=0 then chars(0).xs#=chars(0).xs#/1.4
if chars(0).chardir=0 and chars(0).xs#>-0.05 and chars(0).xs#<0.05 then chars(0).xs#=0.0
`Char speed limt
if chars(0).xs#<-1.0 then chars(0).xs#=-1.0
if chars(0).xs#>1.0 then chars(0).xs#=1.0
`Update player position
inc chars(0).y#,chars(0).ys#
inc chars(0).x#,chars(0).xs#
`Increase player drop rate
dec chars(0).ys#,0.2
if chars(0).ys#<-2.5 then chars(0).ys#=-2.5
colb=character_col(chars(0).x#,chars(0).y#,2.5,4.5)
if colb=1
if character_col(chars(0).x#,chars(0).oldy#,2.5,4.5)=1
chars(0).x#=chars(0).oldx# : chars(0).jump=0
endif
if character_col(chars(0).oldx#,chars(0).y#,2.5,4.5)=1
chars(0).y#=chars(0).oldy# : chars(0).jump=0
if chars(0).ys#<0 then chars(0).ys#=chars(0).ys#*0.5 else chars(0).ys#=0
endif
`Avoid sticking
if character_col(chars(0).x#,chars(0).y#,2.5,4.5)=1
if chars(0).jump=0 and chars(0).charstnd=0
if chars(0).imgnum<3 then chars(0).imgnum=1
if chars(0).imgnum>2 then chars(0).imgnum=3
endif
chars(0).x#=chars(0).oldx# : chars(0).xs#=0.0
chars(0).y#=chars(0).oldy# : chars(0).ys#=0.0
endif
endif
if controlkey()=1 and character_col(chars(0).x#,(chars(0).y#-0.5),2.5,4.5)=1
chars(0).ys#=3.0
chars(0).jump=1
endif
position object 1,chars(0).x#,chars(0).y#,0
return
`----------------`
Enemy_movement:
for y=1 to 5
if chars(y).id>0
if chars(y).health<=0 then chars(y).lives=0
if chars(y).Lives>0
chars(y).charstnd=0
chars(y).oldx#=chars(y).x#
chars(y).oldy#=chars(y).y#
if y<4
if enemy_spike(chars(y).x#,chars(y).y#,chars(y).chardir)=0
if chars(y).x#>chars(0).x# + 10.0
dec chars(y).x#,0.5 : chars(y).chardir=-1 : chars(y).charstnd=-1
endif
if chars(y).x#<chars(0).x# - 10.0
inc chars(y).x#,0.5 : chars(y).chardir=1 : chars(y).charstnd=1
endif
inc chars(y).y#,chars(y).ys#
` Increase player drop rate
dec chars(y).ys#,0.3
if chars(y).ys#<-2.5 then chars(y).ys#=-2.5
endif
endif
if y>3
if chars(y).x#>chars(0).x#-60.0 and chars(y).x#<chars(0).x#+60.0
if chars(y).y#>chars(0).y#-60.0 and chars(y).y#<chars(0).y#+60.0
if chars(y).x#>chars(0).x#+10.0
dec chars(y).x#,0.5 : chars(y).chardir=-1 : chars(y).charstnd=-1
endif
if chars(y).x#<chars(0).x#-10.0
inc chars(y).x#,0.5 : chars(y).chardir=1 : chars(y).charstnd=1
endif
`if chars(y).x#>chars(0).x# -10.0 or chars(y).x#<chars(0).x# +10.0
if chars(y).y#>chars(0).y#
dec chars(y).Y#,0.5 : chars(y).chardirvert=-1
endif
if chars(y).Y#<chars(0).Y#
inc chars(y).Y#,0.5 : chars(y).chardirvert=1
`if chars(y).Y#<chars(0).Y#+10.0 or chars(y).Y#>chars(0).Y#-10.0
`chars(y).Y#=chars(y).oldy#
`endif
endif
endif
endif
endif
if y<4
if enemy_spike(chars(y).x#,chars(y).y#,chars(y).chardir)=1
chars(y).x#=chars(y).oldx#
chars(y).y#=chars(y).oldy#
chars(y).charstnd=0
endif
endif
if Y>3
if saucer_scan(chars(y).X#,chars(y).Y#,chars(y).chardirvert)=1 or 4
if chars(y).Y#>chars(0).Y#+0.5 or chars(y).Y#<chars(0).Y#-0.5
if chars(y).chardir=1 then inc chars(y).X#,0.5
if chars(y).chardir=-1 then dec chars(y).X#,0.5
`chars(y).Y#=chars(y).oldY#
`saucermv=0
`if chars(y).X#>chars(0).X# and saucermv=0 or 1
` inc chars(y).sxtimepls
`saucermv=1
`if chars(y).sxtimepls>10
` chars(y).sxtimepls=0
`chars(y).saucermv=1
`inc chars(y).X#,0.5
`endif
`endif
`if chars(y).X#<chars(0).X# and saucermv=0 or 2
`inc chars(y).sxtimemin
`saucermv=1
`if chars(y).sxtimemin>10
`chars(y).sxtimemin=0
`chars(y).saucermv=2
`dec chars(y).X#,0.5
`endif
`endif
` then dec chars(y).X#,0.5
`if chars(y).X#<chars(0).X# then inc chars(y).X#,0.5
`if chars(y).X#>chars(0).X#-10.0 then dec chars(y).X#,0.5
`if chars(y).X#<chars(0).X#+10.0 then inc chars(y).X#,0.5
`endif
`endif
`if y>3
if enemy_spike(chars(y).x#,chars(y).y#,0)=1
chars(y).x#=chars(y).oldx#
chars(y).y#=chars(y).oldy#
chars(y).charstnd=0
endif
endif
endif
endif
if Y<4
for E=1 to 3
if E<>Y
if chars(y).x#<chars(e).x#+3 and chars(y).x#>chars(e).x#-3
if chars(y).y#<chars(e).y#+5 and chars(y).y#>chars(e).y#-5
chars(y).x#=chars(y).oldx#
`chars(y).y#=chars(y).oldy#
chars(y).charstnd=0
endif
endif
endif
next e
endif
if Y>3
for E=4 to 5
if E<>Y
if chars(y).x#<chars(e).x#+3 and chars(y).x#>chars(e).x#-3
if chars(y).y#<chars(e).y#+5 and chars(y).y#>chars(e).y#-5
chars(y).x#=chars(y).oldx#
`chars(y).y#=chars(y).oldy#
chars(y).charstnd=0
endif
endif
endif
next e
endif
If Y<4
colb=enemy_col(chars(y).x#,chars(y).y#,2.5,4.5)
if colb=1
if enemy_col(chars(y).x#,chars(y).oldy#,2.5,4.5)=1
chars(y).x#=chars(y).oldx# : chars(y).jump=0
endif
if enemy_col(chars(y).oldx#,chars(y).y#,2.5,4.5)=1
chars(y).y#=chars(y).oldy# : chars(y).jump=0
if chars(y).ys#<0 then chars(y).ys#=chars(y).ys#*0.5 else chars(y).ys#=0
endif
`Avoid sticking
if enemy_col(chars(y).x#,chars(y).y#,2.5,4.5)=1
if chars(y).jump=0 and chars(y).charstnd=0
if chars(y).imgnum<3 then chars(y).imgnum=1
if chars(y).imgnum>2 then chars(y).imgnum=3
endif
chars(y).x#=chars(y).oldx#
chars(y).y#=chars(y).oldy# : chars(y).ys#=0.0
chars(y).charstnd=0
endif
endif
chars(y).jumpcounter=((timer()-jtime)/1000)-rnd(2)
if enemy_scan(chars(y).x#,chars(y).y#,chars(y).chardir)=1 and chars(y).jumpcounter=>4
if chars(y).jump=0
inc chars(y).ys#,0.7
chars(y).jump=1
chars(y).jtime=timer()
endif
endif
endif
If Y>3
colb=enemy_col(chars(y).x#,chars(y).y#,2.5,8.0)
if colb=1
if enemy_col(chars(y).x#,chars(y).oldy#,2.5,8.0)=1
chars(y).x#=chars(y).oldx#
endif
if enemy_col(chars(y).oldx#,chars(y).y#,2.5,8.0)=1
chars(y).y#=chars(y).oldy#
if chars(y).ys#<0 then chars(y).ys#=chars(y).ys#*0.5 else chars(y).ys#=0
endif
`Avoid sticking
if enemy_col(chars(y).x#,chars(y).y#,2.5,8.0)=1
if chars(y).charstnd=0
if chars(y).imgnum<3 then chars(y).imgnum=1
if chars(y).imgnum>2 then chars(y).imgnum=3
chars(y).x#=chars(y).oldx#
chars(y).y#=chars(y).oldy#
chars(y).charstnd=0
endif
endif
endif
chars(y).firecounter=((timer()-chars(y).ftime)/1000)-rnd(3)
if chars(y).firecounter=>3
if chars(0).Y#<=(chars(y).Y#+10) and chars(0).Y#=>(chars(y).Y#-10)
if chars(0).X#<=(chars(y).X#+80) and chars(0).X#=>(chars(y).X#-80)
chars(y).bfir=1
gosub Enemy_Add_bullet
chars(y).ftime=timer()
endif
endif
endif
endif
endif
endif
next y
if enbulletcount>0 then gosub Enemy_Move_bullet
return
`----------------
Char_Anim:
for y=0 to 5
if chars(y).id>0
if chars(y).frame>1 then chars(y).frame=0
if chars(y).chardir=-1 or chars(y).chardir=1
inc chars(y).charanimcount
if chars(y).charanimcount=>animcount
if chars(y).chardir=-1
chars(y).imgnum=1+chars(y).frame
endif
if chars(y).chardir=1
chars(y).imgnum=3+chars(y).frame
endif
chars(y).frame=chars(y).frame+1
chars(y).charanimcount=0
endif
endif
if chars(y).charstnd=0
if chars(y).imgnum<3
chars(y).imgnum=1
endif
if chars(y).imgnum>2
chars(y).imgnum=3
endif
endif
if chars(y).jump=1
if chars(y).imgnum<3
chars(y).imgnum=2
chars(y).charstnd=-1
endif
if chars(y).imgnum>2
chars(y).imgnum=4
chars(y).charstnd=1
endif
endif
endif
next y
position object 50,chars(0).X#,chars(0).Y#+2.5,0
texture object 50,chars(0).imgnum
for n=1 to 5
if chars(n).id>0
if chars(n).lives>0
enem=500
enem=enem+n
chars(n).enem=enem
if n<4
if object exist(enem) then delete object enem
clone object enem,51
position object enem,chars(n).x#,chars(n).y#+2.5,0
texture object enem,chars(n).imgnum
endif
if n>3
if object exist(enem) then delete object enem
clone object enem,52
position object enem,chars(n).x#,chars(n).y#+2.5,0
`texture object enem,chars(n).imgnum
endif
endif
if chars(n).lives<=0 and chars(n).dedflg=0
inc chars(n).dedfrm
if chars(n).dedfrm<chars(n).deadanimcount
enemdead=chars(n).enem
hide object enemdead
endif
if chars(n).dedfrm=>chars(n).deadanimcount
enemdead=chars(n).enem
show object enemdead
inc chars(n).deadanimcount,16
endif
if chars(n).dedfrm=>64
enemdead=chars(n).enem
hide object enemdead
chars(n).X#=(-80.0*5.0)-(y+20)
chars(n).Y#=(-80.0*5.0)-(y+20)
chars(n).dedflg=1
endif
endif
endif
next n
return
`-----------------
Player_Add_bullet:
chars(0).ftime=timer()
bdir=chars(0).charfc
if bdir=1 then bdir=2
if bdir=-1 then bdir=-2
for n=0 to maxbullets
if bullets(0,n).bulletfired=0
bullets(0,n).bulletfired=1
bullets(0,n).bulletx#=chars(0).x#
bullets(0,n).bullety#=chars(0).y#
bullets(0,n).bulletdir=bdir
inc plbulletcount
exit
endif
next n
`endif
return
`----------------
Enemy_Add_Bullet:
for x=1 to 5
if chars(y).bfir=1
bdir=chars(y).chardir
if bdir=1 then bdir=2
if bdir=-1 then bdir=-2
for n=0 to maxbullets
if bullets(x,n).bulletfired=0
bullets(x,n).bulletfired=1
bullets(x,n).bulletx#=chars(y).x#
bullets(x,n).bullety#=chars(y).y#
bullets(x,n).bulletdir=bdir
inc enbulletcount
chars(y).bfir=0
exit
endif
next n
endif
next x
return
`----------------
Player_Move_Bullet:
for n=0 to maxbullets
if bullets(0,n).bulletfired=1
bullets(0,n).bulletx#=bullets(0,n).bulletx#+bullets(0,n).bulletdir
pbul=n+200
if object exist(pbul)=1 then delete object pbul
clone object pbul,40
color object pbul,rgb(0,255,0)
position object pbul,bullets(0,n).bulletX#,bullets(0,n).bulletY#+1.8,0
`if x=0
if enemy_col(bullets(0,n).bulletX#,bullets(0,n).bulletY#,2.0,2.0)=1
bullets(0,n).bulletfired=0
dec plbulletcount
delete object pbul
endif
for e=1 to 5
if chars(E).id>0
if bullets(0,n).bulletX#<chars(E).X#+1.0 and bullets(0,n).bulletX#>chars(E).X#-1.0
if bullets(0,n).bulletY#>chars(E).Y#-8.0 and bullets(0,n).bulletY#<chars(E).Y#+8.0
bullets(0,n).bulletfired=0
dec chars(E).health,10
dec plbulletcount
delete object pbul
exit
endif
endif
endif
next e
endif
next n
if plbulletcount<0 then plbulletcount=0
return
`-----------------
Enemy_Move_bullet:
for x=1 to 5
if chars(x).id>0
for n=0 to maxbullets
if bullets(x,n).bulletfired=1
bullets(x,n).bulletx#=bullets(x,n).bulletx#+bullets(x,n).bulletdir
bul=n+250
if object exist(bul)=1 then delete object bul
clone object bul,40
color object bul,rgb(0,255,0)
position object bul,bullets(x,n).bulletX#,bullets(x,n).bulletY#+1.8,0
if enemy_col(bullets(x,n).bulletX#,bullets(x,n).bulletY#,2.0,2.0)=1
bullets(x,n).bulletfired=0
dec enbulletcount
delete object bul
endif
if bullets(x,n).bulletX#<chars(0).X#+1.0 and bullets(x,n).bulletX#>chars(0).X#-1.0
if bullets(x,n).bulletY#>chars(0).Y#-5.0 and bullets(x,n).bulletY#<chars(0).Y#+5.0
bullets(x,n).bulletfired=0
dec chars(0).health,20
dec enbulletcount
delete object bul
endif
endif
endif
if enbulletcount<0 then enbulletcount=0
next n
endif
Next x
return
`----------------
`----------------
pickup:
spin#=timer()
for y=0 to map_y
for x=0 to map_x
if map(x,y).block=2
rotate object map(x,y).id,0,spin#+500,0
endif
next x
next y
return
`----------------
`----------------
Info:
plx=int(plx#/5.0)
ply=int(ply#/5.0)
ink rgb(255,200,0),0
center Text 140,40,Player_name$
ink rgb(200,100,0),0
text 40,60,"HP: "+str$(chars(0).health)+"/100"
Text 40,80,"Time: "+minutes$+":"+seconds$
text 40,100,"Jewel Score/Total: "+str$(jewel_score)+"/"+str$(jewel_count)
text 40,120,"Lives: "+str$(player_lives)
return
`----------------
`----------------
End_Game:
if ending(chars(0).x#,chars(0).y#,jewel_score,jewel_count)=1 or game_restart=1
gosub high_score_table
cls
repeat
cls
Center text 640,552,"Would you like to play again?"
Center text 640,572,"Y/N"
game_restart=0
I$=upper$(inkey$())
if I$="Y" then Gosub main_menu
if I$="N" then end
sync
until I$="Y"
endif
return
`----------------
Spike_col:
if spike(chars(0).x#,chars(0).y#)=1 or chars(0).health<=0
player_lives=player_lives-1
if player_lives<=0
restart=1
repeat
cls
Center text 640,552,"Would you like to play again?"
Center text 640,572,"Y/N"
game_restart=1
I$=upper$(inkey$())
if I$="Y" then Gosub main_menu
if I$="N" then end
sync
until I$="Y"
endif
gosub init
endif
return
`----------------
High_score_table:
H_score$="highscore.dat"
Nms$="names.dat"
fnltm$="final_time.dat"
mins=minutes*60
high_score(0)=1000
if file exist(H_score$)
open to read 1,(h_score$)
for n=0 to 10
read string 1,T$:high_score(n)=val(T$)
next n
endif
close file 1
if file exist(Nms$)
open to read 1,(nms$)
for n=0 to 10
read string 1,player_names$(n)
next n
endif
close file 1
if file exist(fnltm$)
open to read 1,(fnltm$)
for n=0 to 10
read string 1,final_time$(n)
next n
endif
close file 1
Finalt$=minutes$+":"+seconds$
n=11
repeat
dec n
if high_score(n)<=0 then high_score(n)=1000
until high_score(n)<mins+seconds or n=0
for I=10 to n+1 step -1
high_score(I)=high_score(I-1)
player_names$(I)=player_names$(I-1)
final_time$(I)=final_time$(I-1)
next I
high_score(n+1)=mins+seconds
player_names$(n+1)=player_name$
final_time$(n+1)=finalt$
hy=(200)
cls
ink rgb(250,100,0),0
Center text (1280/4),(100),"Name:"
Center text (1280-(1280/4)),(100),"Final Time:"
for n=1 to 10
text (1280/4),hy,str$(n)+": "+player_names$(n)
text (1280-(1280/4)),hy,final_time$(n)
inc hy,50
next n
Center text 640,800,"Press Space Key"
sync
while spc=0
if spacekey()=1 then spc=1
endwhile
delete file "highscore.dat"
delete file "names.dat"
delete file "final_time.dat"
open to write 1,(H_score$)
for n=0 to 10
write string 1,str$(high_score(n))
next n
close file 1
open to write 1,(Nms$)
for n=0 to 10
write string 1,player_names$(n)
next n
close file 1
open to write 1,(fnltm$)
for n=0 to 10
write string 1,final_time$(n)
next n
close file 1
return
`--------------------------------------------------------------------
`----------------------------------------------------------------
`FUNCTIONS
`---------------------------------------------------------
`---------------------------------------------------------
function map_set(y,marker$)
y=map_y-y
for p=1 to map_x+1
pm$=mid$(marker$,p)
x=p-1
if pm$="S"
chars(0).x#=(x*5.0)
chars(0).y#=(y*5.0)
chars(0).id=1
endif
if pm$="X"
for n=1 to 3
if chars(n).id=0
chars(n).x#=(x*5.0)
chars(n).y#=(y*5.0)
chars(n).id=2
exit
endif
next n
endif
if pm$="Z"
for n=4 to 5
if chars(n).id=0
chars(n).x#=(x*5.0)
chars(n).y#=(y*5.0)
chars(n).id=3
exit
endif
next n
endif
for n=1 to len(block$)
if mid$(block$,n)=pm$ then map(x,y).block=n-1
next n
map(x,y).marker$=pm$
next p
endfunction
`----------------
`----------------
function character_col(x#,y#,w#,h#)
col=0
charcol=0
for yy=0 to 2
for xx=0 to 2
xx#=0.0
if xx=2 then xx#=w#
if xx=0 then xx#=0.0-w#
yy#=h#/2.0
if yy=0 then yy#=h#
if yy=2 then yy#=0
col=map_block(x#+xx#,y#+yy#)
if col=1 then charcol=1
if col=2
if map(retx,rety).state=0
inc jewel_score,1
obj=map(retx,rety).id
map(retx,rety).state=1
map(x,y).block=0
hide object obj
if col=4 then charcol=4
char_col(xx,yy)=col
endif
endif
next xx
next yy
endfunction charcol
`--------------------------------------------------------------------------
function enemy_col(x#,y#,w#,h#)
col=0
charcol=0
for yy=0 to 2
for xx=0 to 2
xx#=0.0
if xx=2 then xx#=w#
if xx=0 then xx#=0.0-w#
yy#=h#/2.0
if yy=0 then yy#=h#
if yy=2 then yy#=0
col=map_block(x#+xx#,y#+yy#)
if col=1 then charcol=1
char_col(xx,yy)=col
next xx
next yy
endfunction charcol
`--------------------------------------------------------------------------
function map_block(x#,y#)
x=int(x#/5.0)
y=int(y#/5.0)
if x<0 then x=0
if x>map_x then x=map_x
if y<0 then y=0
if y>map_y then y=map_y
retx=x
rety=y
col=map(x,y).block
endfunction col
`------------------------------------------------
function enemy_scan(x#,y#,dr)
x=int(x#/5.0)
y=int(y#/5.0)
if dr=1 then inc x
if dr=-1 then dec x
if x<0 then x=0
if x>map_x then x=map_x
if y<0 then y=0
if y>map_y then y=map_y
retx=x
rety=y
col=map(x,y).block
endfunction col
`------------------------------------------------
function saucer_scan(x#,y#,dr)
x=int(x#/5.0)
y=int(y#/5.0)
if dr=1 then inc y
if dr=-1 then dec y
if x<0 then x=0
if x>map_x then x=map_x
if y<0 then y=0
if y>map_y then y=map_y
retx=x
rety=y
col=map(x,y).block
endfunction col
`------------------------------------------------
function Ending(plx#,ply#,js,jc)
for y=0 to map_y
for x=0 to map_x
plx=int(plx#/5.0)
ply=int(ply#/5.0)
if plx<0 then plx=0
if plx>map_x then plx=map_x
if ply<0 then ply=0
if ply>map_y then ply=map_y
if map(plx,ply).block=3 and js=jc then finish=1
next x
next y
endfunction Finish
`------------------
`------------------
function spike(plx#,ply#)
spk=0
for y=0 to map_y
for x=0 to map_x
plx=int(plx#/5.0)
ply=int(ply#/5.0)
if plx<0 then plx=0
if plx>map_x then plx=map_x
if ply<0 then ply=0
if ply>map_y then ply=map_y
if map(plx,ply).block=4 then spik=1
next x
next y
endfunction spik
`-------------------------
function enemy_spike(enx#,eny#,endir)
for y=0 to map_y
for x=0 to map_x
enx=int(enx#/5.0)
eny=int(eny#/5.0)
if endir=1 then inc enx
if endir=-1 then dec enx
if enx<0 then enx=0
if enx>map_x then enx=map_x
if eny<0 then eny=0
if eny>map_y then eny=map_y
if map(enx,eny).block=4 then spik=1
next x
next y
endfunction spik
`-------------------
Meep