Urmmm,
You have two do...loops
take out the second do loop (all of this)
Quote: "
do
if spacekey() then end
` if returnkey() then goto continue
sync
loop
"
------------------------------------------------------------------
And in the second snippet you have the two do loops(No Good!) and A reapeat without a while staement.
Just get rid of the repeat command
You only need one or the other the way you are setting it up!
do
rem main loop
rem code ...
rem code ...
rem code ...
sync
loop
you can add the if spacekey()=1 then end if you would like.
Like this...
sync on
rem it's better practice to set the sync rate after turning sync on
sync rate 0
hide mouse
set image colorkey 255,0,255
load image "shipmain.bmp",1
load image "shipE2.bmp",2
load image "greenlazer.bmp",3
load image "yellowlazer.bmp",4
load image "orb.bmp",5
load sound "exsound.wav",1
load sound "sound1.wav",2
load music "space.mp3",1
starquantity = 400
starlayers = 5
speedfactor# = 0.75
` Here we'll setup our starfield type
type starfield
X AS FLOAT
Y AS FLOAT
Z AS INTEGER
speed AS FLOAT
color AS DWORD
endtype
` Now let's create some stars
dim stars(starquantity) as starfield
` We need to give each star a location, colour and depth
for s=0 to starquantity
stars(s).x = rnd(800)
stars(s).y = rnd(600)
stars(s).z = int(s/(starquantity/starlayers))+1
stars(s).speed = stars(s).z * speedfactor#
temp_col = (255/starlayers) * stars(s).z
stars(s).color = rgb(temp_col, temp_col, temp_col)
next s
rem I believe this needs to be outside the main loop
rem Unless you want to reset them each frame
rem ####Initialization of variables & star music
x=250
y=250
pf=0:score=0:Level=1:lives=3
play music 1
loop music 1
rem ############### Now our main loop! ############################
do
cls 0
for s=0 to starquantity
sx# = stars(s).x
dot sx#, stars(s).y, stars(s).color
sx# = sx# - stars(s).speed
if sx# < 0 then sx# = 800
stars(s).x = sx#
next s
rem I don't understand what you are doing here
rem what is ysx & ysy = to also see *
rem sprite 1,ysx,ysy,1
rem I guess sprite 2 never moves. You are using constants here
rem Is that your intention
sprite 2,500,200,2
if upkey()=1 then y=y-5
if downkey()=1 then y=y+5
if rightkey()=1 then x=x+5
if leftkey()=1 then x=x-5
if spacekey()=1 then goto cleanup
rem * And here you are setting sprite 1's position to x,y
sprite 1,x,y,1
sync
loop
rem ############# End of Main Game Loop #########################
cleanup:
cls 0
`It's a good habit to clean up resources in the reverse order they
`were loaded.
`Stop and clean up music and sound.
`Delete Loaded Images
for x=4 to 1 step -1
delete image x
next x
end
Final tips & remaining queations:
Now I don't understand why you are positioning sprite 1 twice per frame, and I am not at a computer with a compiler on it, so perhaps you can expalin that logic to me.