I HATE forgetting stuff so little. Then not even noticing it to a point where I have to ask for help.
EDIT: Hmm, the buttons dont show up, I had them displayed over the image, but they still dont show, I think it may be something with the get image, ill attach the image, maybe you can look it over.
sprite MMS(1), 0, 0, MM(1)
offset sprite MMS(1), sprite x(MMS(1)), sprite y(MMS(1))
set sprite priority MMS(1), 0
sprite MMS(2), 284, 348, MM(2)
offset sprite MMS(2), sprite x(MMS(2)), sprite y(MMS(2))
set sprite priority MMS(2), 1
sprite MMS(3), 266, 356, MM(3)
offset sprite MMS(3), sprite x(MMS(3)), sprite y(MMS(3))
set sprite priority MMS(3), 1
sprite MMS(4), 283, 380, MM(4)
offset sprite MMS(4), sprite x(MMS(4)), sprite y(MMS(4))
set sprite priority MMS(4), 1
do
mx = mousex() : my = mousey() : mc = mouseclick()
if mx => 284 and mx =< 354 and my => 348 and my =< 383
if mc = 1
end
else
set sprite alpha MMS(2), rnd(200)
endif
endif
if mx => 266 and mx =< 274 and my => 356 and my =< 333
if mc = 1
load()
else
set sprite alpha MMS(3), 200
endif
endif
if mx => 283 and mx =< 208 and my => 380 and my =< 258
if mc = 1
gosub game
endif
else
set sprite alpha MMS(4), 200
endif
sync
if spacekey() = 1 then exit
loop
end
EDIT TWO: Still not working, but ive worked on the code, bullets and enemies still arent working, despite it being much better, If someone can look it over and tell me what im doing wrong that would help me alot.
rem |=-------------=|
rem |=-Still-Dying-=|
rem |=-------------=|
rem
rem |=---Coders:---=|
rem
rem |=-Darkzombies-=|
rem
rem |=---Artists:--=|
rem
rem |=----NONE-----=|
rem
rem |=----Index:---=|
rem
rem 1: char (img = 1, spr = 1)
rem 2: bullet (img = 2, spr = 17-23)
rem 3: GameOver (img = 3, spr = 3)
rem 4: enemy (img = 1, spr = 4-10)
rem 5: wall (img = 5, spr = 11)
rem 6: MM (img = 6-10, spr = 12-16)
rem 7:
rem Init
disable escapekey
#constant false 0
#constant true 1
scrhgt = screen height()
scrwid = screen width()
global paused = false
sync on : sync rate 100
color backdrop rgb(0,0,0)
set window title " Some Name - Some Company "
rem Types
type entity
x as integer
y as integer
id as integer
shots as integer
health as integer
lives as integer
amount as integer
endtype
type shot
y as integer
x as integer
id as integer
state as integer
amount as integer
endtype
rem Globals
player as entity
player.id = 1
dim enemy(7) as entity
for x = 1 to 7
for y = 4 to 10
enemy(x).id = y
next y
next x
dim bullets(5) as shot
for b = 1 to 5
for y = 17 to 23
bullets(b).state = false
bullets(b).id = y
bullets(b).amount = 0
next y
next b
global gamestate = 1
global enemydelay = 20000
global time = timer()
global desttime = time
desttime = desttime + enemydelay
global available = 4
global movespeed = 2
global char=1
global bullet=2
global GameOver=3
global wall=5
global wallSprite=11
global dim MM(4)
for mm = 1 to 4
for mmm = 6 to 10
MM(mm)=mmm
next mmm
next mm
global dim MMS(4)
for mms = 1 to 4
for mmss = 12 to 16
MMS(mms)=mmss
next mmss
next mms
rem Make images/Load images
circle 10,10,10
get image char, 0, 0, 22, 22
cls
set text font "Impact"
set text size 50
center text screen width()/2, screen height()/2, "Game Over!"
center text screen width()/2, screen height()/3, "Press 'escape' to exit!"
get image GameOver,0,0,640,480
cls
set text font "Ariel"
set text size 15
load bitmap "media\Main_Menu.png", MM(1) `Main Menu
get image MM(2), 284, 354, 348, 383 `Exit Button
get image MM(3), 266, 274, 356, 333 `Load Game Button
get image MM(4), 283, 208, 380, 258 `New Game Button
delete bitmap MM(1)
load image "media\Main_Menu_Blank.png", MM(1)
game:
rem Init area
sprite player.id, screen width()/2, 400, char
fadeIn(player.id, 500, 0)
player.health = 1000
player.lives = 3
player.x = sprite x(player.id)
player.y = sprite y(player.id)
mainloop:
rem Main loop
do
select gamestate
case 1
playerinput()
enemytimer()
check()
text 50, 50, "Health: "+str$(player.health)
text 50, 60, "Lives: "+str$(player.lives)
for b = 1 to 5
if bullets(b).state=true then movebullet()
next b
player.health = player.health - 1
sync
endcase
case 2
goto mainmenu
endcase
case 3
goto options `(?)
endcase
endselect
loop
rem Main Menu
mainmenu:
sprite MMS(1), 0, 0, MM(1)
offset sprite MMS(1), sprite x(MMS(1)), sprite y(MMS(1))
set sprite priority MMS(1), 0
sprite MMS(2), 284, 348, MM(2)
offset sprite MMS(2), sprite x(MMS(2)), sprite y(MMS(2))
set sprite priority MMS(2), 1
sprite MMS(3), 266, 356, MM(3)
offset sprite MMS(3), sprite x(MMS(3)), sprite y(MMS(3))
set sprite priority MMS(3), 1
sprite MMS(4), 283, 380, MM(4)
offset sprite MMS(4), sprite x(MMS(4)), sprite y(MMS(4))
set sprite priority MMS(4), 1
do
mx = mousex() : my = mousey() : mc = mouseclick()
if mx => 284 and mx =< 354 and my => 348 and my =< 383
if mc = 1
end
else
set sprite alpha MMS(2), 200
endif
endif
if mx => 266 and mx =< 274 and my => 356 and my =< 333
if mc = 1
load()
else
set sprite alpha MMS(3), 200
endif
endif
if mx => 283 and mx =< 208 and my => 380 and my =< 258
if mc = 1
gamestate = 1
endif
else
set sprite alpha MMS(4), 200
endif
sync
if spacekey() = 1 then exit
loop
end
rem Options (Maybe)
options:
print "This is options!"
rem Functions
function playerinput()
` Check for right arrow
if rightkey() = 1
player.x = sprite x(player.id)
if player.x => 617
player.x = sprite x(player.id)
else
player.x = player.x + 2
endif
endif
` Check for left arrow
if leftkey() = 1
player.x = sprite x(player.id)
if player.x =< 3
player.x = sprite x(player.id)
else
player.x = player.x - 2
endif
endif
if spacekey() = 1
if bullets(b).amount < 5
for b = 1 to 5
inc bullets(b).amount
bullets(b).x = sprite x(player.id)
next b
endif
endif
` Show the player (after the x and y may have changed)
sprite player.id, player.x, player.y, char
endfunction
function check() `Checks a whole load of things.
if player.health =< 0
dec player.lives
if player.lives < 0
fadeOut(player.id, 500, 255)
hide all sprites
sprite GameOver, 0, 0, GameOver
fadeIn(GameOver, 500, 0)
do
cls
sprite GameOver, 0, 0, GameOver
if escapekey() = 1 then end
sync
loop
endif
fadeOut(player.id, 0, 255)
sprite player.id, screen width()/2, 400, char
player.health = 100
player.x = screen width()/2
player.y = 400
fadeIn(player.id, 500, 0)
endif
if escapekey() = 1
wait 0500
if paused = false
paused = true
repeat
cls
center text screen width()/2, screen height()/2, "Paused!"
sync
if escapekey() = 1
paused = false
wait 0500
endif
until paused = false
endif
endif
endfunction
rem Decides when an enemy should enter play
function enemytimer()
if timer() > desttime
wait 0200
for b = 1 to 7
if enemy(b).amount < 7
enemy(b).x = rnd(600)+20
enemy(b).y = 0
sprite enemy(b).id, enemy(b).x, 0 - 2, char
inc enemy(b).amount
time = timer()
desttime = time + enemydelay
endif
next b
endif
endfunction
rem Handles bullets.
function movebullet()
for b = 1 to 5
if bullets(b).state = true
x = sprite x(bullets(b).id) : y = sprite y(bullets(b).id)
if x < 0 or x > ScrWid then bullets(b).state = false : hide sprite bullets(b).id : exit
if y < 0 or y > ScrHgt then bullets(b).state = false : hide sprite bullets(b).id : exit
sprite bullets(b).id,bullets(b).x,bullets(b).y + 2, bullet
endif
next b
endfunction
function fadeIn(spr, tmp, alpha_value) `Sprite number, offset, and starting alpha value.
set sprite alpha spr, alpha_value
offset = tmp / 255
tmr = timer() + offset
alpha_value = alpha_value
repeat
if timer() > tmr then inc alpha_value : tmr = timer() + offset : set sprite alpha spr, alpha_value
sync
until alpha_value = 255
endfunction
function fadeOut(spr, tmp, alpha_value)
set sprite alpha spr, 255
offset = tmp / 255
tmr = timer() + offset
alpha_value = alpha_value
repeat
if timer() > tmr then dec alpha_value : tmr = timer() + offset : set sprite alpha spr, alpha_value
sync
until alpha_value = 0
endfunction
EDIT THREE: Ok, I also have a problem with my space game, it either doesnt place an enemy every 20 seconds, or just doesnt move them.
rem |=-------------------=|
rem |=---Falling-Stars---=|
rem |=-------------------=|
rem |=---By-Darkzombies--=|
rem |=-------------------=|
rem |=-------INDEX-------=|
rem |=---Image-Numbers---=|
rem 1: ship =|
rem 2: laser =|
rem 3: =|
rem 4: =|
rem 5: =|
rem |=---Sprite-Numbers--=|
rem 1: player =|
rem 2: enemy (2-5) =|
rem 3: laser (6-11) =|
rem 4: =|
rem 5: =|
rem |=-------------------=|
rem Init
set display mode 800, 600, 16
set window size desktop width(), desktop height()
maximize window
set window off
#constant false 0
#constant true 1
rem Types
type spaceship
x as integer
y as integer
id as integer
w as integer
h as integer
state as integer
endtype
type shot
x as integer
y as integer
id as integer
state as integer
endtype
rem Globals
player as spaceship
dim enemy(4) as spaceship `Max enemies on-screen
dim laser(5) as shot `Max shots on-screen
player.id = 1
scrwid = screen width()
scrhgt = screen height()
global ship = 1
global currenemy = 1
load image "media\spaceship.png", ship
sync on : sync rate 60 : hide mouse : randomize timer()
white=rgb(255, 255, 255)
star = 3
lock pixels
for i = 2 to 1001
dot rnd(ScrWid),rnd(ScrHgt),white
next i
unlock pixels
get image star,0,0,ScrWid,ScrHgt
make object plain 10,20,20
texture object 10,star
move camera 20
sprite player.id, screen width()/2, screen height()/2, ship
player.x = screen width()/2
player.y = screen height()/2
player.w = sprite width(player.id)/2
player.h = sprite height(player.id)/2
rotate sprite player.id, 90
offset sprite player.id, player.w, player.h
for b = 1 to 4
for y = 2 to 5
enemy(b).id = y
enemy(b).x = 220
enemy(b).y = 660
next y
next b
for b = 1 to 5
for y = 6 to 11
laser(b).state = false `Set them to inactive
laser(b).id = y
next y
next b
desttime = timer() + 1000 `FOR TESTING!
do
playerinput()
scroll() `Changed it to scroll, because its going to scroll the enemies too.
for b = 1 to 5
if laser(b).state = true then movelasers()
next b
sync
loop
function playerinput()
` Check for right arrow
if rightkey() = 1
player.x = sprite x(player.id)
if player.x => 760
player.x = sprite x(player.id)
else
player.x = player.x + 4
endif
endif
` Check for left arrow
if leftkey() = 1
player.x = sprite x(player.id)
if player.x =< 40
player.x = sprite x(player.id)
else
player.x = player.x - 4
endif
endif
if upkey() = 1
player.y = sprite y(player.id)
if player.y =< 40
player.y = sprite y(player.id)
else
player.y = player.y - 4
endif
endif
if downkey() = 1
player.y = sprite y(player.id)
if player.y => 560
player.y = sprite y(player.id)
else
player.y = player.y + 4
endif
endif
for b = 1 to 4
dec enemy(b).x, 2
sprite enemy(b).id, enemy(b).x, enemy(b).y, ship
next b
` Show the player (after the x and y may have changed)
sprite player.id, player.x, player.y, ship
endfunction
function movelasers()
for b = 1 to 5
if laser(b).state = true
x = sprite x(laser(b).id) : y = sprite y(laser(b).id)
if x < 0 or x > ScrWid then laser(b).state = false : hide sprite laser(b).id : exit
if y < 0 or y > ScrHgt then laser(b).state = false : hide sprite laser(b).id : exit
inc laser(b).y, 2
sprite laser(b).id,laser(b).x,laser(b).y, laser
endif
next b
endfunction
function scroll()
for x = 1 to 4
sprite enemy(x).id, enemy(x).x + .004, enemy(x).y, ship
next x
scroll object texture 10,.004,0.0
text 10,10,"FPS: " + str$( screen fps() )
sprite player.id, player.x, player.y, ship
sync
endfunction
function enemies()
time=timer()
if time=>desttime
if currenemy > 7 then exit
sprite enemy(currenemy).id, 660, 220, ship
enemy(currenemy).x = 660
enemy(currenemy).y = 220
inc currenemy
desttime = timer() + 20000 `20 second intervals
endif
endfunction
Still need help with my other problem as well.