Discord
Login
Community
DARK THEME

need help with camera stuff

Hello, i'm making a game with a friend of mine, and it was all going smoothly until the world just simply didn't work. then the player just wouldn't appear on screen, or maybe he wouldn't appear where the camera was focused, which i believe was in 0, 0. can someone help me? the code is: init = function() player = object x = -490 y = 218 speed = 2 facing = 1 end

racer1 = object x = -490 y = 210 speed = 2 facing = 1 end end

update = function() if keyboard.LEFT then player.x -= player.speed player.facing = -1 end if keyboard.RIGHT then player.x += player.speed player.facing = 1 end if keyboard.UP then player.y += player.speed end if keyboard.DOWN then player.y -= player.speed end if keyboard.SHIFT then player.speed = 3.5 end if keyboard.release.SHIFT then player.speed = 2 end player.x = clamp (player.x, -1024/2 + 20,1024/2 - 20) player.y = clamp (player.y, -512/2 + 20,512/2 - 20) end draw = function() screen.fillRect(0,0,1024,512,"rgb(124,197,87") screen.drawMap("world" , 0-camera.x,0-camera.y,1024+100,512) screen.drawMap("world" , 0-camera.x,0-camera.y,1024,512) screen.drawSprite( "cookie_shop", 0 -camera.x ,50 -camera.y, 50, 50 ) screen.setDrawScale(player.facing,1) screen.drawSprite("player2",player.x - camera.x,player.y - camera.y, 30,30)

end init = function() end

update = function() end

draw = function()

screen.fillRect(0,0,1024,512,"rgb(124,197,87") screen.drawMap("world" , 0-camera.x,0-camera.y,1024+100,512) screen.drawMap("world" , 0-camera.x,0-camera.y,1024,512) screen.drawSprite( "cookie_shop", 0 -camera.x ,50 -camera.y, 50, 50 )

end init = function() camera = object x = 0 y = 0 end end

update = function() camera.x = player1.x camera.y = player1.y

camera.x = clamp(camera.x,-300,300) camera.y = clamp(camera.y,-156,156) end

and then there mrLman's helpers file.

thanks for answering me! i'm this will be very useful!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community