-
-
Save videlais/657c784c085e0505340b3f8f9a9eaead to your computer and use it in GitHub Desktop.
Update image for player.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create a player table | |
player = {} | |
-- Add an image from the filename "player.png" | |
player.image = love.graphics.newImage( "player.png" ) | |
-- Create a new physics body in the world and make it "dynamic" | |
-- The new coordinates will be where the 'body' is going forward. | |
-- Anytime (like for drawing) the x,y is needed, use getX() and getY() | |
player.body = love.physics.newBody( world, 100, 100, "dynamic" ) | |
-- Make a rectangle shape with: | |
-- Starting at 100, 100 (player.body:getX() and player.body:getY() ) | |
-- a width of player.image:getWidth() | |
-- a height of player.image.getHeight() | |
player.shape = love.physics.newRectangleShape( | |
player.body:getX(), | |
player.body:getY(), | |
player.image:getWidth(), | |
player.image:getHeight() | |
) | |
-- Attach the shape to the body | |
player.fixture = love.physics.newFixture(player.body, player.shape, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment