fixbug and camera restart
BIN
android/game.apk
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest package="love.to.android0105101448"
|
<manifest package="love.to.android0106213437"
|
||||||
android:versionCode="15"
|
android:versionCode="15"
|
||||||
android:versionName="0.9.2"
|
android:versionName="0.9.2"
|
||||||
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
@ -12,13 +12,13 @@
|
|||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="Game 0105101448"
|
android:label="Game 0106213437"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||||
<service android:name=".DownloadService" />
|
<service android:name=".DownloadService" />
|
||||||
<activity
|
<activity
|
||||||
android:name="LtaActivity"
|
android:name="LtaActivity"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="Game 0105101448"
|
android:label="Game 0106213437"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="landscape" >
|
android:screenOrientation="landscape" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest package="love.to.android0105101448"
|
<manifest package="love.to.android0106213437"
|
||||||
android:versionCode="15"
|
android:versionCode="15"
|
||||||
android:versionName="0.9.2"
|
android:versionName="0.9.2"
|
||||||
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
@ -12,13 +12,13 @@
|
|||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="Game 0105101448"
|
android:label="Game 0106213437"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||||
<service android:name=".DownloadService" />
|
<service android:name=".DownloadService" />
|
||||||
<activity
|
<activity
|
||||||
android:name="LtaActivity"
|
android:name="LtaActivity"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="Game 0105101448"
|
android:label="Game 0106213437"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="landscape" >
|
android:screenOrientation="landscape" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#Last build type
|
#Last build type
|
||||||
#Thu, 05 Jan 2017 10:14:55 +0100
|
#Fri, 06 Jan 2017 21:34:44 +0100
|
||||||
|
|
||||||
build.last.target=debug
|
build.last.target=debug
|
||||||
|
|
||||||
|
@ -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.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/android0106213437/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/android0106213437/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/android0106213437/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/android0106213437/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/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/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$1.class \
|
||||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$2.class \
|
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$2.class \
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# view AndroidManifest.xml #generated:45
|
# view AndroidManifest.xml #generated:45
|
||||||
-keep class love.to.android0105101448.DownloadActivity { <init>(...); }
|
-keep class love.to.android0106213437.DownloadActivity { <init>(...); }
|
||||||
|
|
||||||
# view AndroidManifest.xml #generated:17
|
# view AndroidManifest.xml #generated:17
|
||||||
-keep class love.to.android0105101448.DownloadService { <init>(...); }
|
-keep class love.to.android0106213437.DownloadService { <init>(...); }
|
||||||
|
|
||||||
# view AndroidManifest.xml #generated:18
|
# view AndroidManifest.xml #generated:18
|
||||||
-keep class love.to.android0105101448.LtaActivity { <init>(...); }
|
-keep class love.to.android0106213437.LtaActivity { <init>(...); }
|
||||||
|
|
||||||
|
@ -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/res/drawable-xxhdpi/ic_launcher.png \
|
||||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/AndroidManifest.xml \
|
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/AndroidManifest.xml \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/** Automatically generated file. DO NOT MODIFY */
|
/** Automatically generated file. DO NOT MODIFY */
|
||||||
package love.to.android0105101448;
|
package love.to.android0106213437;
|
||||||
|
|
||||||
public final class BuildConfig {
|
public final class BuildConfig {
|
||||||
public final static boolean DEBUG = true;
|
public final static boolean DEBUG = true;
|
@ -5,7 +5,7 @@
|
|||||||
* should not be modified by hand.
|
* should not be modified by hand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package love.to.android0105101448;
|
package love.to.android0106213437;
|
||||||
|
|
||||||
public final class R {
|
public final class R {
|
||||||
public static final class attr {
|
public static final class attr {
|
@ -1,4 +1,4 @@
|
|||||||
package love.to.android0105101448;
|
package love.to.android0106213437;
|
||||||
import org.love2d.android.GameActivity;
|
import org.love2d.android.GameActivity;
|
||||||
|
|
||||||
public class LtaActivity extends GameActivity {}
|
public class LtaActivity extends GameActivity {}
|
@ -21,9 +21,11 @@ function game.load()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function game.update(dt)
|
function game.update(dt)
|
||||||
if game.die then
|
end
|
||||||
game.lifes = game.lifes - 1
|
|
||||||
game.die = false
|
function game.draw()
|
||||||
|
if DEBUG then
|
||||||
|
love.graphics.print('FPS: ' .. love.timer.getFPS(), 50, 50)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,17 +6,17 @@ function controls.load(game)
|
|||||||
-- Button left
|
-- Button left
|
||||||
local img_button_left = love.graphics.newImage('assets/sprites/gui/button_left.png')
|
local img_button_left = love.graphics.newImage('assets/sprites/gui/button_left.png')
|
||||||
local left_x = PADDING
|
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)
|
controls.new_button('button_left', left_x, left_y, img_button_left)
|
||||||
-- Button right
|
-- Button right
|
||||||
local img_button_right = love.graphics.newImage('assets/sprites/gui/button_right.png')
|
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_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)
|
controls.new_button('button_right', right_x, right_y, img_button_right)
|
||||||
-- Button up
|
-- Button up
|
||||||
local img_button_up = love.graphics.newImage('assets/sprites/gui/button_up.png')
|
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_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)
|
controls.new_button('button_up', up_x, up_y, img_button_up)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,29 +30,27 @@ function life.load(game)
|
|||||||
y_target = life.top.y + (life.top.img:getHeight() / 2),
|
y_target = life.top.y + (life.top.img:getHeight() / 2),
|
||||||
width = 10,
|
width = 10,
|
||||||
color = {0, 0, 0},
|
color = {0, 0, 0},
|
||||||
angle = 230,
|
angle = 300,
|
||||||
move_up = false,
|
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)
|
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)
|
love.graphics.setLineWidth(life.indicator.width)
|
||||||
life.indicator.limits = {}
|
-- Filter red
|
||||||
life.indicator.limits[2] = {
|
life.filter = {
|
||||||
min = 260,
|
color = {255, 255, 255},
|
||||||
max = 270
|
temp_num_lifes = game.lifes
|
||||||
}
|
|
||||||
life.indicator.limits[3] = {
|
|
||||||
min = 230,
|
|
||||||
max = 240
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function life.update(dt, game)
|
function life.update(dt, game)
|
||||||
life.top.animation:update(dt)
|
life.top.animation:update(dt)
|
||||||
-- Direction
|
-- 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
|
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
|
life.indicator.move_up = true
|
||||||
end
|
end
|
||||||
-- Increment
|
-- Increment
|
||||||
@ -63,17 +61,28 @@ function life.update(dt, game)
|
|||||||
end
|
end
|
||||||
-- Calculate pos indicator
|
-- 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)
|
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
|
end
|
||||||
|
|
||||||
function life.draw()
|
function life.draw(game)
|
||||||
-- Background top
|
-- Background top
|
||||||
life.top.animation:draw(life.top.img, life.top.x, life.top.y)
|
life.top.animation:draw(life.top.img, life.top.x, life.top.y)
|
||||||
-- Indicator
|
-- Indicator
|
||||||
love.graphics.setColor(life.indicator.color)
|
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.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
|
-- 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
|
end
|
||||||
|
|
||||||
return life
|
return life
|
@ -7,13 +7,20 @@ spaceship.y = 0
|
|||||||
local press_button = false
|
local press_button = false
|
||||||
|
|
||||||
function spaceship.load(game)
|
function spaceship.load(game)
|
||||||
-- power origin 1000
|
body = {
|
||||||
body = { x = game.canvas.width / 2, y = 0 , power = 400 , size_collition = 28, polygons_collition = 8 }
|
x = 0,
|
||||||
|
y = 0,
|
||||||
|
power = 400,
|
||||||
|
size_collition = 28,
|
||||||
|
polygons_collition = 8
|
||||||
|
}
|
||||||
body.width = 156
|
body.width = 156
|
||||||
body.height = 143
|
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.img = love.graphics.newImage('assets/sprites/spaceship/body.png')
|
||||||
body.num_frames = 5
|
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.shape = love.physics.newCircleShape(20)
|
||||||
body.fixture = love.physics.newFixture(body.body, body.shape, 1)
|
body.fixture = love.physics.newFixture(body.body, body.shape, 1)
|
||||||
body.fixture:setRestitution(0.9)
|
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)
|
body.collision.hc:moveTo(body.body:getX() + body.collision.claim, body.body:getY() + body.collision.claim)
|
||||||
-- Check for collisions
|
-- Check for collisions
|
||||||
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
|
for shape, delta in pairs(HC.collisions(body.collision.hc)) do
|
||||||
game.play = false
|
if game.die == false then
|
||||||
game.die = true
|
-- Lose life
|
||||||
explosion.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
|
if game.lifes > 1 then
|
||||||
explosion.animation:resume()
|
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
|
end
|
||||||
if not game.play then
|
if not game.play then
|
||||||
body.body:setLinearVelocity(0, 0)
|
body.body:setLinearVelocity(0, 0)
|
||||||
@ -120,6 +134,25 @@ function spaceship.update(dt, game)
|
|||||||
x, y = body.body:getLinearVelocity()
|
x, y = body.body:getLinearVelocity()
|
||||||
body.body:setLinearVelocity(-x, y)
|
body.body:setLinearVelocity(-x, y)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function spaceship.draw(game)
|
function spaceship.draw(game)
|
||||||
|
BIN
assets/sprites/gui/button_left.png
Normal file → Executable file
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
assets/sprites/gui/button_right.png
Normal file → Executable file
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
assets/sprites/gui/button_up.png
Normal file → Executable file
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
assets/sprites/gui/life_down.png
Normal file → Executable file
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 6.3 KiB |
3
main.lua
@ -36,6 +36,7 @@ end
|
|||||||
|
|
||||||
-- DRAW
|
-- DRAW
|
||||||
function love.draw()
|
function love.draw()
|
||||||
|
game.draw()
|
||||||
camera.gcam:draw(function(l,t,w,h)
|
camera.gcam:draw(function(l,t,w,h)
|
||||||
background.draw()
|
background.draw()
|
||||||
moon.draw()
|
moon.draw()
|
||||||
@ -43,7 +44,7 @@ function love.draw()
|
|||||||
asteroids.draw()
|
asteroids.draw()
|
||||||
end)
|
end)
|
||||||
controls.draw()
|
controls.draw()
|
||||||
life.draw()
|
life.draw(game)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- CONTROLS
|
-- CONTROLS
|
||||||
|