Progress life indicator
BIN
android/game.apk
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="love.to.android0103235155"
|
||||
<manifest package="love.to.android0105101448"
|
||||
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 0103235155"
|
||||
android:label="Game 0105101448"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<service android:name=".DownloadService" />
|
||||
<activity
|
||||
android:name="LtaActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="Game 0103235155"
|
||||
android:label="Game 0105101448"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="landscape" >
|
||||
<intent-filter>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="love.to.android0103235155"
|
||||
<manifest package="love.to.android0105101448"
|
||||
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 0103235155"
|
||||
android:label="Game 0105101448"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<service android:name=".DownloadService" />
|
||||
<activity
|
||||
android:name="LtaActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="Game 0103235155"
|
||||
android:label="Game 0105101448"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="landscape" >
|
||||
<intent-filter>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#Last build type
|
||||
#Tue, 03 Jan 2017 23:52:00 +0100
|
||||
#Thu, 05 Jan 2017 10:14:55 +0100
|
||||
|
||||
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/love/to/android0103235155/BuildConfig.class \
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103235155/LtaActivity.class \
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103235155/R$attr.class \
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103235155/R$drawable.class \
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103235155/R.class \
|
||||
/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/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 \
|
||||
|
@ -1,9 +1,9 @@
|
||||
# view AndroidManifest.xml #generated:45
|
||||
-keep class love.to.android0103235155.DownloadActivity { <init>(...); }
|
||||
-keep class love.to.android0105101448.DownloadActivity { <init>(...); }
|
||||
|
||||
# view AndroidManifest.xml #generated:17
|
||||
-keep class love.to.android0103235155.DownloadService { <init>(...); }
|
||||
-keep class love.to.android0105101448.DownloadService { <init>(...); }
|
||||
|
||||
# view AndroidManifest.xml #generated:18
|
||||
-keep class love.to.android0103235155.LtaActivity { <init>(...); }
|
||||
-keep class love.to.android0105101448.LtaActivity { <init>(...); }
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android0103235155/R.java \
|
||||
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android0105101448/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 \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package love.to.android0103235155;
|
||||
package love.to.android0105101448;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
@ -5,7 +5,7 @@
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package love.to.android0103235155;
|
||||
package love.to.android0105101448;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
@ -1,4 +1,4 @@
|
||||
package love.to.android0103235155;
|
||||
package love.to.android0105101448;
|
||||
import org.love2d.android.GameActivity;
|
||||
|
||||
public class LtaActivity extends GameActivity {}
|
@ -3,6 +3,8 @@ local game = {}
|
||||
function game.load()
|
||||
-- Configuration
|
||||
math.randomseed(os.time())
|
||||
PADDING = 50
|
||||
game.lifes = 3
|
||||
local width, height = love.window.getDesktopDimensions( display )
|
||||
game.window = { width = width , height = height }
|
||||
game.canvas = { width = width, height = 2880 }
|
||||
|
@ -3,21 +3,20 @@ local controls = {}
|
||||
local BUTTONS = {}
|
||||
|
||||
function controls.load(game)
|
||||
local padding = 50
|
||||
-- Button left
|
||||
local img_button_left = love.graphics.newImage('assets/sprites/hui/button_left.png')
|
||||
local left_x = padding
|
||||
local left_y = (game.window.height / 3 * 2) - img_button_left:getHeight() - padding
|
||||
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
|
||||
controls.new_button('button_left', left_x, left_y, img_button_left)
|
||||
-- Button right
|
||||
local img_button_right = love.graphics.newImage('assets/sprites/hui/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 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
|
||||
controls.new_button('button_right', right_x, right_y, img_button_right)
|
||||
-- Button up
|
||||
local img_button_up = love.graphics.newImage('assets/sprites/hui/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 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
|
||||
controls.new_button('button_up', up_x, up_y, img_button_up)
|
||||
end
|
||||
|
59
assets/scripts/gui/life.lua
Normal file
@ -0,0 +1,59 @@
|
||||
local anim8 = require 'assets/scripts/vendor/anim8'
|
||||
local tools = require 'assets/scripts/tools'
|
||||
|
||||
local life = {}
|
||||
|
||||
function life.load(game)
|
||||
local PADDING = 50
|
||||
-- Up
|
||||
life.top = {
|
||||
x = PADDING,
|
||||
y = PADDING,
|
||||
img = love.graphics.newImage('assets/sprites/gui/life_top.png'),
|
||||
num_frames = 2
|
||||
}
|
||||
g = anim8.newGrid(life.top.img:getWidth() / life.top.num_frames, life.top.img:getHeight(), life.top.img:getWidth(), life.top.img:getHeight())
|
||||
life.top.animation = anim8.newAnimation(g('1-' .. life.top.num_frames, 1), 1)
|
||||
life.top.animation:gotoFrame(1)
|
||||
life.top.animation:pause()
|
||||
-- Down
|
||||
life.down = {
|
||||
img = love.graphics.newImage('assets/sprites/gui/life_down.png'),
|
||||
x = PADDING,
|
||||
y = life.top.y + life.top.img:getHeight()
|
||||
}
|
||||
-- Indicator
|
||||
life.indicator = {
|
||||
x_shaft = life.down.x + (life.down.img:getWidth() / 2),
|
||||
y_shaft = life.down.y + (life.down.img:getHeight() / 2),
|
||||
x_target = life.top.x + (life.top.img:getWidth() / 2 / life.top.num_frames),
|
||||
y_target = life.top.y + (life.top.img:getHeight() / 2),
|
||||
width = 10,
|
||||
color = {0, 0, 0},
|
||||
angle = 230,
|
||||
move_up = false
|
||||
}
|
||||
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)
|
||||
end
|
||||
|
||||
function life.update(dt, game)
|
||||
life.top.animation:update(dt)
|
||||
-- 1 230 240
|
||||
if game.life == 3 then
|
||||
end
|
||||
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)
|
||||
end
|
||||
|
||||
function life.draw()
|
||||
-- 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)
|
||||
-- Background down
|
||||
love.graphics.draw(life.down.img, life.down.x, life.down.y)
|
||||
end
|
||||
|
||||
return life
|
@ -71,4 +71,15 @@ function tools.print_r(t)
|
||||
print()
|
||||
end
|
||||
|
||||
function tools.distance(x1, y1, x2, y2)
|
||||
local dx = x1 - x2
|
||||
local dy = y1 - y2
|
||||
return math.sqrt ( dx * dx + dy * dy )
|
||||
end
|
||||
|
||||
function tools.circle_position(angle, radius, x_center, y_center)
|
||||
local angle_temp = angle * math.pi / 180
|
||||
return x_center + radius * math.cos(angle_temp), y_center + radius * math.sin(angle_temp)
|
||||
end
|
||||
|
||||
return tools
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
assets/sprites/gui/life_down.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
assets/sprites/gui/life_top.png
Normal file
After Width: | Height: | Size: 49 KiB |
6
main.lua
@ -3,7 +3,8 @@ local background = require 'assets/scripts/background'
|
||||
local spaceship = require 'assets/scripts/spaceship'
|
||||
local asteroids = require 'assets/scripts/asteroids'
|
||||
local moon = require 'assets/scripts/moon'
|
||||
local controls = require 'assets/scripts/controls'
|
||||
local controls = require 'assets/scripts/gui/controls'
|
||||
local life = require 'assets/scripts/gui/life'
|
||||
local camera = require 'assets/scripts/camera'
|
||||
|
||||
-- LOAD
|
||||
@ -15,6 +16,7 @@ function love.load()
|
||||
moon.load(game)
|
||||
spaceship.load(game)
|
||||
controls.load(game)
|
||||
life.load(game)
|
||||
end
|
||||
|
||||
-- UPDATE
|
||||
@ -27,6 +29,7 @@ function love.update(dt)
|
||||
asteroids.update(dt, game)
|
||||
moon.update()
|
||||
spaceship.update(dt, game)
|
||||
life.update(dt, game)
|
||||
camera.update(game, spaceship)
|
||||
end
|
||||
|
||||
@ -39,6 +42,7 @@ function love.draw()
|
||||
asteroids.draw()
|
||||
end)
|
||||
controls.draw()
|
||||
life.draw()
|
||||
end
|
||||
|
||||
-- CONTROLS
|
||||
|