Quote: "Yeah... still didn't work, can someone visually explain how I'm messing up lol. It would help alot."
I know NonZero showed you later but if you ran the second code snip of my last message you would of seen a visual of what it was grabbing back on the 7th.
Quote: "But for some reason now its having the background follow my mouse and not the shadow images O.O
Do you think its grabbing from the background image instead or something?"
It's because you do this for the background image:
BG = GetFreeSprite()
load image "media\BG.bmp", BG
paste image BG, 0, 0
If you didn't catch it... your checking for a free sprite for the background image. It's nice to be able to have an automatic system like this for big projects where it's too many images/sprites to track. But for small games it's best to just create a list of all the image numbers and sprite numbers you use for the game in a REMSTART/REMEND.
remstart
Images
1 - First Alien Frame 1
2 - First Alien Frame 2
3 - Second Alien Frame 1
4 - Second Alien Frame 2
5 - Third Alien Frame 1
6 - Third Alien Frame 2
7 - Alien Mothership
8 - Player Ship
9 - Player Explosion Frame 1
10 - Player Explosion Frame 2
11 - Alien Explosion
12 - Mothership Explosion
28 - Main Background (blank black screen)
29 - Red Colored Area
30 - Green Colored Area 1
31 - Green Colorer Area 2
32 - 90 - Font
remend
Also it's a good idea to have some text to show whats going on with the variables in the program.
Your code with TEXT commands (without other changes):
Rem =---------------------------------------=
rem =----------The Lonely Shadow------------=
rem =-Started on: Sunday, November 06, 2011-=
rem =-----------By: Darkzombies-------------=
rem =---------------------------------------=
rem CONSTANTS
#constant false 0
#constant true 1
rem GLOBALS AND ARRAYS
global currsprite, currimage, gamestate
dim shadow(3)
rem TYPES
type Coord
x
y
endtype
type Entity
x as float
y as float
id as integer
speed as float
direction as integer
jumpdelay as integer
animdelay as integer
jumping as boolean
falling as boolean
health as integer
frame as integer
endtype
type Landscape
id as integer
x as float
y as float
size as Coord
endtype
player as Entity
rem INIT
gosub LoadMedia
gosub SetupPlayer
gosub SetupTerrain
gosub SetupEnemies
sync on : sync rate 100
gamestate = 1
rem MAIN LOOP
do
` Show the variables
text 0,0,"player.x = "+str$(player.x)
text 0,20,"player.y = "+str$(player.y)
text 0,40,"player.id = "+str$(player.id)
text 0,60,"player.frame = "+str$(player.frame)
text 0,80,"shadow(player.frame) = "+str$(shadow(player.frame))
text 0,100,"player.animdelay = "+str$(player.animdelay)
text 0,120,"BG = "+str$(BG)
text 0,140,"currsprite = "+str$(currsprite)
text 0,160,"currimage = "+str$(currimage)
text 0,180,"gamestate = "+str$(gamestate)
select gamestate
case 1
`PlayerInput()
sprite player.id, mousex(), mousey(), shadow(player.frame)
if player.animdelay > timer()
inc player.frame
player.animdelay = timer() + 1000
else
inc player.animdelay
endif
if player.frame>3 then player.frame=1
sync
endcase
case 2
rem Main Menu
endcase
case 3
rem Map Editor (I figured it was time to learn about that as well.)
endcase
endselect
loop
rem SUBROUTINES
SetupTerrain:
dim Terrain(100) as Landscape `Max sprites for terrain.
for b = 1 to 100
Terrain(b).id = GetFreeSprite()
rem Maybe I can
next b
SetupPlayer:
player.x = 0
player.y = 1010
player.id = GetFreeSprite()
player.frame = 1
inc player.x, 10
sprite player.id, player.x, player.y, shadow(player.frame)
mirror sprite player.id
return
SetupEnemies:
return
LoadMedia:
` Load the image as a bitmap
load bitmap "media\Shadows.png",1
set current bitmap 1
for b = 1 to 3
shadow(b) = GetFreeImage()
get image shadow(b), (b - 1) * 32, 0, b * 32, 32
next b
delete bitmap 1
set current bitmap 0
BG = GetFreeSprite()
load image "media\BG.bmp", BG
paste image BG, 0, 0
return
rem FUNCTIONS
function PlayerInput()
if rightkey()=1
inc player.x
if player.direction = 0 then mirror sprite player.id
player.direction = 1
endif
if leftkey()=1
dec player.x
if player.direction = 1 then mirror sprite player.id
player.direction = 0
endif
if spacekey()=1
player.jumping = true
player.jumpdelay = timer()+1000 `Rise for a second before falling.
if timer() > player.jumpdelay
player.jumping = false
player.falling = true
dec player.y
else
inc player.y
endif
endif
endfunction
function GetFreeSprite()
repeat
inc currsprite
until sprite exist(currsprite) = false
endfunction currsprite
function GetFreeImage()
repeat
inc currimage
until image exist(currimage) = false
endfunction currimage