mike: placed ball and player into an 'actors' table; blocks will also go here
This commit is contained in:
parent
e6c1ecb364
commit
46c7910eaa
2
love/mike/.gitignore
vendored
2
love/mike/.gitignore
vendored
@ -1 +1 @@
|
||||
save_game/*
|
||||
save_game/savefile.lua
|
||||
|
@ -14,7 +14,7 @@ function love.keyreleased(key)
|
||||
-- save
|
||||
elseif key == SAVE_KEY then
|
||||
--love.filesystem.write(saveFile, Tserial.pack(player, false, true))
|
||||
GameState.save(player, "player")
|
||||
GameState.save(actors, "actors")
|
||||
|
||||
-- Load
|
||||
elseif key == LOAD_KEY then
|
||||
|
@ -9,26 +9,31 @@ function love.load()
|
||||
screen.width = love.graphics.getWidth()
|
||||
screen.height = love.graphics.getHeight()
|
||||
|
||||
-- Create a table to hold all actors
|
||||
actors = {}
|
||||
|
||||
-- Create a table to hold all the player data
|
||||
player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
|
||||
actors.player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
|
||||
-- Create a table to hold ball data
|
||||
ball = create_object(screen.width /2, screen.height /2, 1, 1, 600)
|
||||
ball.x_speed = (ball.speed /2)
|
||||
ball.y_speed = (ball.speed /2)
|
||||
actors.ball = create_object(screen.width /2, screen.height /2, 1, 1, 600)
|
||||
actors.ball.x_speed = (actors.ball.speed /2)
|
||||
actors.ball.y_speed = (actors.ball.speed /2)
|
||||
|
||||
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
player = check_keys(player, screen, dt)
|
||||
ball = ball_bounce(player, ball, dt)
|
||||
actors.player = check_keys(actors.player, screen, dt)
|
||||
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
--Draw paddle
|
||||
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
|
||||
love.graphics.rectangle("line", actors.player.x, actors.player.y,
|
||||
actors.player.width, actors.player.height)
|
||||
--Draw ball
|
||||
love.graphics.rectangle("line", ball.x, ball.y, ball.width, ball.height)
|
||||
love.graphics.rectangle("line", actors.ball.x, actors.ball.y,
|
||||
actors.ball.width, actors.ball.height)
|
||||
--FPS counter
|
||||
love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
||||
end
|
||||
|
@ -1 +0,0 @@
|
||||
player = { x = 266, y = 550, width = 30, height = 5, speed = 500, }
|
Loading…
x
Reference in New Issue
Block a user