Add animation fire spaceship and light

This commit is contained in:
Andros Fenollosa 2016-11-27 11:06:22 +01:00
parent b86c084b28
commit fc553ac58f
24 changed files with 52 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest package="love.to.android1126182250" <manifest package="love.to.android1126182750"
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 1126182250" android:label="Game 1126182750"
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 1126182250" android:label="Game 1126182750"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="landscape" > android:screenOrientation="landscape" >
<intent-filter> <intent-filter>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest package="love.to.android1126182250" <manifest package="love.to.android1126182750"
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 1126182250" android:label="Game 1126182750"
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 1126182250" android:label="Game 1126182750"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="landscape" > android:screenOrientation="landscape" >
<intent-filter> <intent-filter>

View File

@ -1,5 +1,5 @@
#Last build type #Last build type
#Sat, 26 Nov 2016 18:22:56 +0100 #Sat, 26 Nov 2016 18:27:55 +0100
build.last.target=debug 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.dex : \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182250/BuildConfig.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182750/BuildConfig.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182250/LtaActivity.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182750/LtaActivity.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182250/R$attr.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182750/R$attr.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182250/R$drawable.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182750/R$drawable.class \
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182250/R.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1126182750/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 \

View File

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

View File

@ -1,3 +1,3 @@
/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android1126182250/R.java \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android1126182750/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 \

View File

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

View File

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

View File

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

View File

@ -1,29 +1,53 @@
local anim8 = require 'assets/scripts/vendor/anim8' local anim8 = require 'assets/scripts/vendor/anim8'
local spaceship = {} local spaceship = {}
local press_button = false
function spaceship.load(game) function spaceship.load(game)
-- power origin 1000 -- power origin 1000
spaceship = { x = game.canvas.width / 2, y = 0 , power = 400 , size_collition = 28, polygons_collition = 8 } spaceship = { x = game.canvas.width / 2, y = 0 , power = 400 , size_collition = 28, polygons_collition = 8 }
spaceship.width = 156
spaceship.height = 143
spaceship.img = love.graphics.newImage('assets/sprites/spaceship/body.png') spaceship.img = love.graphics.newImage('assets/sprites/spaceship/body.png')
spaceship.body = love.physics.newBody(game.world, (game.canvas.width / 2) - (spaceship.img:getWidth() / 2) , spaceship.y, 'dynamic') spaceship.body = love.physics.newBody(game.world, (game.canvas.width / 2) - (spaceship.img:getWidth() / 2) , spaceship.y, 'dynamic')
spaceship.shape = love.physics.newCircleShape(20) spaceship.shape = love.physics.newCircleShape(20)
spaceship.fixture = love.physics.newFixture(spaceship.body, spaceship.shape, 1) spaceship.fixture = love.physics.newFixture(spaceship.body, spaceship.shape, 1)
spaceship.fixture:setRestitution(0.9) spaceship.fixture:setRestitution(0.9)
local g = anim8.newGrid(110, 103, spaceship.img:getWidth(), spaceship.img:getHeight()) local g = anim8.newGrid(spaceship.width, spaceship.height, spaceship.img:getWidth(), spaceship.img:getHeight())
spaceship.animation = anim8.newAnimation(g('1-1', 1), 0.1) spaceship.animation_stop = anim8.newAnimation(g('1-1', 1), 0.1)
spaceship.animation_fire = anim8.newAnimation(g('2-5', 1), 0.01)
-- Light
light = {
img = love.graphics.newImage('assets/sprites/spaceship/light.png'),
y = spaceship.y
}
light.x = spaceship.x + (spaceship.img:getWidth() / 2) + (light.img:getWidth() / 2)
light.num_frames = 9
light.width = 16
light.height = 16
g = anim8.newGrid(light.width, light.height, light.img:getWidth(), light.img:getHeight())
light.animation = anim8.newAnimation(g('1-' .. light.num_frames, 1), 0.1)
end end
function spaceship.update(dt) function spaceship.update(dt)
spaceship.animation:update(dt) -- Spaceship
spaceship.animation_fire:update(dt)
press_button = false
-- Light
light.animation:update(dt)
light.x = spaceship.body:getX() + (spaceship.width / 2) + (light.width / 2)
light.y = spaceship.body:getY()
-- Controls -- Controls
if control_up then if control_up then
spaceship.body:applyForce(0, -spaceship.power) spaceship.body:applyForce(0, -spaceship.power)
press_button = true
end end
if control_right then if control_right then
spaceship.body:applyForce(spaceship.power, 0) spaceship.body:applyForce(spaceship.power, 0)
press_button = true
elseif control_left then elseif control_left then
spaceship.body:applyForce(-spaceship.power, 0) spaceship.body:applyForce(-spaceship.power, 0)
press_button = true
end end
if control_quit then if control_quit then
love.event.push('quit') love.event.push('quit')
@ -31,7 +55,12 @@ function spaceship.update(dt)
end end
function spaceship.draw() function spaceship.draw()
spaceship.animation:draw(spaceship.img, spaceship.body:getX(), spaceship.body:getY()) light.animation:draw(light.img, light.x, light.y)
if press_button then
spaceship.animation_fire:draw(spaceship.img, spaceship.body:getX(), spaceship.body:getY())
else
spaceship.animation_stop:draw(spaceship.img, spaceship.body:getX(), spaceship.body:getY())
end
end end
return spaceship return spaceship

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB