fixbug and camera restart

This commit is contained in:
Andros Fenollosa 2017-01-06 21:36:57 +01:00
parent 52929bdd84
commit 0e70e85984
31 changed files with 93 additions and 48 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="love.to.android0105101448"
<manifest package="love.to.android0106213437"
android:versionCode="15"
android:versionName="0.9.2"
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
@ -12,13 +12,13 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Game 0105101448"
android:label="Game 0106213437"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<service android:name=".DownloadService" />
<activity
android:name="LtaActivity"
android:configChanges="orientation|screenSize"
android:label="Game 0105101448"
android:label="Game 0106213437"
android:launchMode="singleTop"
android:screenOrientation="landscape" >
<intent-filter>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="love.to.android0105101448"
<manifest package="love.to.android0106213437"
android:versionCode="15"
android:versionName="0.9.2"
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
@ -12,13 +12,13 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Game 0105101448"
android:label="Game 0106213437"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<service android:name=".DownloadService" />
<activity
android:name="LtaActivity"
android:configChanges="orientation|screenSize"
android:label="Game 0105101448"
android:label="Game 0106213437"
android:launchMode="singleTop"
android:screenOrientation="landscape" >
<intent-filter>

View File

@ -1,5 +1,5 @@
#Last build type
#Thu, 05 Jan 2017 10:14:55 +0100
#Fri, 06 Jan 2017 21:34:44 +0100
build.last.target=debug

View File

@ -1,9 +1,9 @@
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes.dex : \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0105101448/BuildConfig.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0105101448/LtaActivity.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0105101448/R$attr.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0105101448/R$drawable.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0105101448/R.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0106213437/BuildConfig.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0106213437/LtaActivity.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0106213437/R$attr.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0106213437/R$drawable.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0106213437/R.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/DummyEdit.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$1.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$2.class \

View File

@ -1,9 +1,9 @@
# view AndroidManifest.xml #generated:45
-keep class love.to.android0105101448.DownloadActivity { <init>(...); }
-keep class love.to.android0106213437.DownloadActivity { <init>(...); }
# view AndroidManifest.xml #generated:17
-keep class love.to.android0105101448.DownloadService { <init>(...); }
-keep class love.to.android0106213437.DownloadService { <init>(...); }
# view AndroidManifest.xml #generated:18
-keep class love.to.android0105101448.LtaActivity { <init>(...); }
-keep class love.to.android0106213437.LtaActivity { <init>(...); }

View File

@ -1,3 +1,3 @@
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android0105101448/R.java \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android0106213437/R.java \
: /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/AndroidManifest.xml \

View File

@ -1,5 +1,5 @@
/** Automatically generated file. DO NOT MODIFY */
package love.to.android0105101448;
package love.to.android0106213437;
public final class BuildConfig {
public final static boolean DEBUG = true;

View File

@ -5,7 +5,7 @@
* should not be modified by hand.
*/
package love.to.android0105101448;
package love.to.android0106213437;
public final class R {
public static final class attr {

View File

@ -1,4 +1,4 @@
package love.to.android0105101448;
package love.to.android0106213437;
import org.love2d.android.GameActivity;
public class LtaActivity extends GameActivity {}

View File

@ -21,9 +21,11 @@ function game.load()
end
function game.update(dt)
if game.die then
game.lifes = game.lifes - 1
game.die = false
end
function game.draw()
if DEBUG then
love.graphics.print('FPS: ' .. love.timer.getFPS(), 50, 50)
end
end

View File

@ -6,17 +6,17 @@ function controls.load(game)
-- Button left
local img_button_left = love.graphics.newImage('assets/sprites/gui/button_left.png')
local left_x = PADDING
local left_y = (game.window.height / 3 * 2) - img_button_left:getHeight() - PADDING
local left_y = game.window.height - img_button_left:getHeight() - PADDING
controls.new_button('button_left', left_x, left_y, img_button_left)
-- Button right
local img_button_right = love.graphics.newImage('assets/sprites/gui/button_right.png')
local right_x = game.window.width - (img_button_right:getWidth() / 2) - PADDING
local right_y = (game.window.height / 3 * 2) - img_button_right:getHeight() - PADDING
local right_y = game.window.height - img_button_right:getHeight() - PADDING
controls.new_button('button_right', right_x, right_y, img_button_right)
-- Button up
local img_button_up = love.graphics.newImage('assets/sprites/gui/button_up.png')
local up_x = game.window.width - (img_button_up:getWidth() / 2) - PADDING
local up_y = (game.window.height / 3) - img_button_up:getHeight() - PADDING
local up_y = right_y - img_button_up:getHeight() - PADDING
controls.new_button('button_up', up_x, up_y, img_button_up)
end

View File

@ -30,29 +30,27 @@ function life.load(game)
y_target = life.top.y + (life.top.img:getHeight() / 2),
width = 10,
color = {0, 0, 0},
angle = 230,
angle = 300,
move_up = false,
vel = 1
vel = 0.3,
limits = {310, 270, 230},
angle_variation = 3
}
life.indicator.radius = tools.distance(life.indicator.x_shaft, life.indicator.y_shaft, life.indicator.x_target, life.indicator.y_target)
love.graphics.setLineWidth(life.indicator.width)
life.indicator.limits = {}
life.indicator.limits[2] = {
min = 260,
max = 270
}
life.indicator.limits[3] = {
min = 230,
max = 240
-- Filter red
life.filter = {
color = {255, 255, 255},
temp_num_lifes = game.lifes
}
end
function life.update(dt, game)
life.top.animation:update(dt)
-- Direction
if life.indicator.limits[game.lifes].max < life.indicator.angle then
if life.indicator.limits[game.lifes] < life.indicator.angle then
life.indicator.move_up = false
elseif life.indicator.limits[game.lifes].min > life.indicator.angle then
elseif life.indicator.limits[game.lifes] - life.indicator.angle_variation > life.indicator.angle then
life.indicator.move_up = true
end
-- Increment
@ -63,17 +61,28 @@ function life.update(dt, game)
end
-- Calculate pos indicator
life.indicator.x_target, life.indicator.y_target = tools.circle_position(life.indicator.angle, life.indicator.radius, life.indicator.x_shaft, life.indicator.y_shaft)
-- Filter
if life.filter.temp_num_lifes ~= game.lifes then
life.filter.color = {255, 0, 0}
life.filter.temp_num_lifes = game.lifes
end
for key, color in pairs(life.filter.color) do
if color < 255 then
life.filter.color[key] = life.filter.color[key] + 1
end
end
end
function life.draw()
function life.draw(game)
-- Background top
life.top.animation:draw(life.top.img, life.top.x, life.top.y)
-- Indicator
love.graphics.setColor(life.indicator.color)
love.graphics.line(life.indicator.x_shaft, life.indicator.y_shaft, life.indicator.x_target, life.indicator.y_target)
love.graphics.setColor(255, 255, 255)
-- Filter
love.graphics.setColor(life.filter.color)
-- Background down
love.graphics.draw(life.down.img, life.down.x, life.down.y)
love.graphics.draw(life.down.img, life.down.x, life.down.y - 1)
end
return life

View File

@ -7,13 +7,20 @@ spaceship.y = 0
local press_button = false
function spaceship.load(game)
-- power origin 1000
body = { x = game.canvas.width / 2, y = 0 , power = 400 , size_collition = 28, polygons_collition = 8 }
body = {
x = 0,
y = 0,
power = 400,
size_collition = 28,
polygons_collition = 8
}
body.width = 156
body.height = 143
body.pos_center_x = (game.canvas.width / 2) - (body.width / 2)
body.x = body.pos_center_x
body.img = love.graphics.newImage('assets/sprites/spaceship/body.png')
body.num_frames = 5
body.body = love.physics.newBody(game.world, (game.canvas.width / 2) - (body.img:getWidth() / 2) , body.y, 'dynamic')
body.body = love.physics.newBody(game.world, body.x , body.y, 'dynamic')
body.shape = love.physics.newCircleShape(20)
body.fixture = love.physics.newFixture(body.body, body.shape, 1)
body.fixture:setRestitution(0.9)
@ -99,10 +106,17 @@ function spaceship.update(dt, game)
body.collision.hc:moveTo(body.body:getX() + body.collision.claim, body.body:getY() + body.collision.claim)
-- Check for collisions
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
game.play = false
game.die = true
explosion.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
explosion.animation:resume()
if game.die == false then
-- Lose life
if game.lifes > 1 then
game.lifes = game.lifes - 1
end
-- Die
game.die = true
game.play = false
explosion.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
explosion.animation:resume()
end
end
if not game.play then
body.body:setLinearVelocity(0, 0)
@ -120,6 +134,25 @@ function spaceship.update(dt, game)
x, y = body.body:getLinearVelocity()
body.body:setLinearVelocity(-x, y)
end
-- Check if this ingame
local x, y = body.body:getPosition()
if y < 0 then
body.body:setPosition(x, 0)
end
if y > game.canvas.height then
game.play = false
end
-- Restart position
if not game.play then
body.body:setLinearVelocity(0, -1000)
if y <= 0 then
local y = 0
body.body:setLinearVelocity(0, 0)
body.body:setPosition(body.pos_center_x, y)
game.play = true
game.die = false
end
end
end
function spaceship.draw(game)

BIN
assets/sprites/gui/button_left.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/sprites/gui/button_right.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

BIN
assets/sprites/gui/button_up.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
assets/sprites/gui/life_down.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -36,6 +36,7 @@ end
-- DRAW
function love.draw()
game.draw()
camera.gcam:draw(function(l,t,w,h)
background.draw()
moon.draw()
@ -43,7 +44,7 @@ function love.draw()
asteroids.draw()
end)
controls.draw()
life.draw()
life.draw(game)
end
-- CONTROLS