Add explosion

This commit is contained in:
Andros Fenollosa 2016-12-08 20:49:38 +01:00
parent 2af855e88a
commit 0bf3f6926e
25 changed files with 54 additions and 26 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.android1208185535"
<manifest package="love.to.android1208204140"
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 1208185535"
android:label="Game 1208204140"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<service android:name=".DownloadService" />
<activity
android:name="LtaActivity"
android:configChanges="orientation|screenSize"
android:label="Game 1208185535"
android:label="Game 1208204140"
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.android1208185535"
<manifest package="love.to.android1208204140"
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 1208185535"
android:label="Game 1208204140"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<service android:name=".DownloadService" />
<activity
android:name="LtaActivity"
android:configChanges="orientation|screenSize"
android:label="Game 1208185535"
android:label="Game 1208204140"
android:launchMode="singleTop"
android:screenOrientation="landscape" >
<intent-filter>

View File

@ -1,5 +1,5 @@
#Last build type
#Thu, 08 Dec 2016 18:55:42 +0100
#Thu, 08 Dec 2016 20:41:46 +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/android1208185535/BuildConfig.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208185535/LtaActivity.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208185535/R$attr.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208185535/R$drawable.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208185535/R.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208204140/BuildConfig.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208204140/LtaActivity.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208204140/R$attr.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208204140/R$drawable.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1208204140/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.android1208185535.DownloadActivity { <init>(...); }
-keep class love.to.android1208204140.DownloadActivity { <init>(...); }
# view AndroidManifest.xml #generated:17
-keep class love.to.android1208185535.DownloadService { <init>(...); }
-keep class love.to.android1208204140.DownloadService { <init>(...); }
# view AndroidManifest.xml #generated:18
-keep class love.to.android1208185535.LtaActivity { <init>(...); }
-keep class love.to.android1208204140.LtaActivity { <init>(...); }

View File

@ -1,3 +1,3 @@
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android1208185535/R.java \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android1208204140/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.android1208185535;
package love.to.android1208204140;
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.android1208185535;
package love.to.android1208204140;
public final class R {
public static final class attr {

View File

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

View File

@ -8,6 +8,7 @@ function game.load()
game.canvas = { width = width, height = 2880 }
love.window.setMode(game.window.width, game.window.height)
game.level = 1
game.play = true
-- Physics
local world_meter = 64
local gravity = 2

View File

@ -31,6 +31,19 @@ function spaceship.load(game)
light.height = 66
g = anim8.newGrid(light.width, light.height, light.img:getWidth(), light.img:getHeight())
light.animation = anim8.newAnimation(g('1-' .. light.num_frames, 1), 0.05)
-- Explosion
explosion = {
img = love.graphics.newImage('assets/sprites/spaceship/explosion.png'),
num_frames = 10,
speed = 0.05,
x = -game.canvas.width,
y = -game.canvas.height
}
g = anim8.newGrid(explosion.img:getWidth() / explosion.num_frames, explosion.img:getHeight(), explosion.img:getWidth(), explosion.img:getHeight())
explosion.animation = anim8.newAnimation(g('1-' .. explosion.num_frames, 1), explosion.speed, 'pauseAtEnd')
explosion.animation:pause()
explosion.claim_x = 45
explosion.claim_y = 40
-- Collision
body.collision = {}
body.collision.claim = 79
@ -64,6 +77,8 @@ function spaceship.update(dt, game)
light.animation:update(dt)
light.x = body.body:getX() + 43
light.y = body.body:getY() - 15
-- Explosion
explosion.animation:update(dt)
-- Controls
if control_up then
body.body:applyForce(0, -body.power)
@ -84,6 +99,12 @@ 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
explosion.x, explosion.y, explosion.enable = body.body:getX() - explosion.claim_x, body.body:getY() - explosion.claim_y, true
explosion.animation:resume()
end
if not game.play then
body.body:setLinearVelocity(0, 0)
end
-- Check game limits
if body.body:getY() <= 0 then -- Top game
@ -100,13 +121,19 @@ function spaceship.update(dt, game)
end
end
function spaceship.draw()
function spaceship.draw(game)
if game.play then
-- Lignt
light.animation:draw(light.img, light.x, light.y)
-- Spaceship
if press_button then
body.animation_fire:draw(body.img, body.body:getX(), body.body:getY())
else
body.animation_stop:draw(body.img, body.body:getX(), body.body:getY())
end
end
-- Explosion
explosion.animation:draw(explosion.img, explosion.x, explosion.y)
-- Collision
if collision_debug then
body.collision.hc:draw('fill')

View File

@ -33,7 +33,7 @@ function love.draw()
camera.gcam:draw(function(l,t,w,h)
background.draw()
moon.draw()
spaceship.draw()
spaceship.draw(game)
asteroids.draw()
end)
controls.draw()