The code of my card is very simple (see below). The stack script has the updateScreen generation from the GameAcademy.
The first line "local sGameRunning" is being reported as shadowing something (it'd be very handy if the compiler would point to where the duplicate definition actually is).
If I do cmd-f to find, then click 'More...', and then select Look in: Stack File and its stackFiles, that should be broad enough to find all occurances, yes?
I find it defined below, and used 3 times below, but no other declarations or uses.
So, what is it I'm not understanding? Clearly I'm getting it wrong, but where?
-Ken
Code: Select all
local sGameRunning
local sAcc
local sImageHeight
local bobbot
local sImageTop
local isectBob
on startGame
activateScreenUpdates
put height of image "bob" into sImageHeight
put true into sGameRunning
set bottom of image "bob" to 687
end startGame
on stopGame
put false into sGameRunning
stopUpdatingTheScreen
end stopGame
on handleKey
put the keysDown into field "keysdown"
-- move left
if 65361 is in the keysDown then
set left of image "bob" to left of image "bob" - 10
end if
-- move right
if 65363 is in the keysDown then
set left of image "bob" to left of image "bob" + 10
end if
-- jump
if 65362 is in the keysDown then
if sAcc = 0 then
put 15 into sAcc
end if
end if
-- crouch
if 65364 is in the keysDown then
put bottom of image "bob" into bobbot
set height of image "bob" to sImageHeight/2
set bottom of image "bob" to bobbot
else
put bottom of image "bob" into bobbot
set height of image "bob" to sImageHeight
set bottom of image "bob" to bobbot
end if
end handleKey
on intersectBob
put false into isectBob
-- Now check to see if we collide with the floor
if intersect(image "bob",graphic "floor0",127) then
put "floor0" after field "keysdown"
put false into isectBob
end if
if intersect(image "bob",graphic "floor1",127) then
put "floor1" after field "keysdown"
put false into isectBob
end if
if intersect(image "bob",graphic "floor2",127) then
put "floor2" after field "keysdown"
put false into isectBob
end if
if intersect(image "bob",graphic "floor3",127) then
put "floor3" after field "keysdown"
put false into isectBob
end if
end intersectBob
on moveBob
-- This gives us gravity: a constant acceleration downwards.
set top of image "bob" to top of image "bob" -sAcc
put sAcc - 0.9 into sAcc
end moveBob
on updateScreen
if sGameRunning then
handleKey
moveBob
if mouse(1) is "down" then
put the keysDown into x
if "left" is in x then
put x into y
end if
put x into y
end if
end if
end updateScreen