Discord
Login
Community
DARK THEME

is there a special alignment i needa to to have a tilt at around 20-50 degrees?

im making a system in which the floor in which you are are ( a hill) basically changes in angle wintin 20 - 50 degrees as long as it goes on. when I just set it to drawsprite, nothing is actually aligned, instead the sprites are in the same pos but in a different angle. Im new here and idk how to fix it cause the idea was to have the whole screen (beside the background and the UI) to be rotated.

screen.drawRotaion does exactly that. It rotates the object by a given angle.


update = function()
   angle += 1
end

draw = function()
  screen.clear()
  screen.setDrawRotation( angle )
  screen.drawSprite("icon", 50, 50, 20, 20 )
  screen.drawSprite("icon", -50, 50, 25, 25 )
  screen.drawSprite("icon", 50, -50, 30, 30 )
  screen.drawSprite("icon", -50, -50, 35, 35 )
  screen.drawSprite("icon", 0, 0, 40, 20 )
end

If you want to change the coordinates, you have to calculate them using trugonometric functions.

update = function()
   angle += 1
end

// drawing after rotation around the axis
daraa = function( centerAxisX, centerAxisY, rX, rY, angle )
  local x = centerAxisX + cosd( angle ) * rX
  local y = centerAxisY + sind( angle ) * rY
  screen.drawSprite( "icon", x, y, 10, 10 )
end

draw = function()
  screen.clear()
  screen.setDrawRotation( angle )
  screen.drawSprite("icon", 50, 50, 20, 20 )
  screen.drawSprite("icon", -50, 50, 25, 25 )
  screen.drawSprite("icon", 50, -50, 30, 30 )
  screen.drawSprite("icon", -50, -50, 35, 35 )
  screen.drawSprite("icon", 0, 0, 40, 20 )
  daraa( 0, 0, 100, 100 , angle )
  daraa( 50, 50, 25, 25 , angle )  
  daraa( -50, 50, 25, 25 , -angle )
  daraa( -50, -50, 25, 125 , angle )  
end

damn alr

actually im kinda curious cause my friend is doing this is this useable for the tutorial? hes making the jump thing but the screen flips for some reason

Set rotation to default value.

draw = function()
   screen.setDrawRotation(0)
   //..............................
end

Post a reply

Progress

Status

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