HELP !!
i'm developing an educational chemistry game (5 levels, 25 lessons) with microStudio. ^o^ i have implemented a camera system to explore the laboratory, but I am encountering a classic problem: my sprites (lesson buttons) correctly follow the camera movements, but their collision detectors (mouse) remain at their initial coordinates.my.My QUESTION!!! is: how can I make the virtual collision detectors move as well?????
initBouton = function()
bouton = object
x = 165
y = 60
width = 62
height = 52
end
bouton1 = object
x = -170
y = 65
width = 40
height = 40
end
bouton2 = object
x = 0
y = -60
width = 30
height = 30
animation = false
clique = false
end
Bouton = class
constructor = function(x, y, width, height, id, fini)
this.x = x
this.y = y
this.width = width
this.height = height
this.id = id
this.fini = fini
end
end
list_bouton = []
list_bouton.push(new Bouton(-210, -20, 40, 40, "Tuto", false))
list_bouton.push(new Bouton(-150, -30,40,40,"lesson1",false))
end
checkRectMouseHover = function(x, y, width, height)
local hover = true
if mouse.x < (x - width/2) then hover = false end
if mouse.x > (x + width/2) then hover = false end
if mouse.y < (y - height/2) then hover = false end
if mouse.y > (y + height/2) then hover = false end
return hover
end
updateBouton = function()
if scene == "menu" then
if checkRectMouseHover(bouton.x, bouton.y, bouton.width, bouton.height) then
bouton.width = 60
bouton.height = 40
if mouse.press then scene = "langue" end
else
bouton.width = 50
bouton.height = 30
end
for p in list_bouton
if checkRectMouseHover(p.x, p.y, p.width, p.height) then
p.width = 50
p.height = 50
else
p.width = 40
p.height = 40
end
end
end
if scene == "langue" then
if checkRectMouseHover(bouton1.x, bouton1.y, bouton1.width, bouton1.height) then
bouton1.width = 50
bouton1.height = 50
if mouse.press then scene = "menu" end
else
bouton1.width = 40
bouton1.height = 40
end
if checkRectMouseHover(bouton2.x, bouton2.y, bouton2.width, bouton2.height) then
bouton2.width = 40
bouton2.height = 40
else
bouton2.width = 30
bouton2.height = 30
end
if checkRectMouseHover(bouton2.x, bouton2.y, bouton2.width, bouton2.height) and mouse.press then
if bouton2.clique == false then
bouton2.clique = true
bouton2.animation = true
langue = "anglais"
else
bouton2.clique = false
bouton2.animation = false
langue = "francais"
end
end
end
end
drawBouton = function()
if scene == "menu" then
if langue == "francais" then
screen.drawSprite("graphique/tile7_a", bouton.x, bouton.y, bouton.width, bouton.height)
screen.drawText("FR", 165, 90, 15, "rgb(57,255,189)")
elsif langue == "anglais" then
screen.drawSprite("graphique/tile7_b", bouton.x + 2, bouton.y, bouton.width, bouton.height)
screen.drawText("EN", 165, 90, 15, "rgb(57,255,189)")
end
for p in list_bouton
if not p.fini then
screen.drawSprite("graphique/tile5_a", p.x - camera.x, p.y - camera.y, p.width, p.height)
end
end
end
if scene == "langue" then
screen.drawSprite("graphique/tile2_c", bouton1.x , bouton1.y , bouton1.width, bouton1.height)
end
end
//here the CAMERA CODE !!! >_<
initCamera = function()
camera = object
x = 0
y = 0
end
end
updateCamera = function()
camera.x = clamp(scotio.x, -258, 258)
camera.y = clamp(scotio.y, -389,389)
end
clamp = function(value, lower_limit, upper_limit)
local val = max(value, lower_limit)
val = min(val, upper_limit)
return val
end
scotio = object
x = 0
y = 0
lon = 30
lar = 30
vitesse = 3
gauche = false
idle = true
droite = false
end
updatePlayer = function()
if keyboard.LEFT then scotio.x -= player.vitesse end
if keyboard.RIGHT then scotio.x += player.vitesse end
scotio.x = clamp(scotio.x, - 100, 100)
end
drawPlayer = function()
screen.drawSprite( "graphique/tile10_b", scotio.x - scotio.x, scotio.y - camera.y, scotio..lon, scotio.lar)
end

