Added Barrel

You spin me right round, baby
Right round like a record, baby
Right round round round
This commit is contained in:
Mike Schwörer 2015-09-17 12:34:58 +02:00
parent 34fe132efa
commit 3be4b2cab2
13 changed files with 113 additions and 22 deletions

BIN
android/assets/barrel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 801 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 218 B

View File

@ -18,7 +18,8 @@ public class CannonGame extends AgdxGame {
setDebugFont(new BitmapFont(Gdx.files.internal("consolefont.fnt")));
settings.debugVisualMenu.set(false);
settings.debugMenuLayerTextInfos.set(false);
settings.debugMenuLayerTextInfos.set(true);
settings.debugGameLayerMenuTextInfos.set(false);
settings.debugEnabled.set(true);
}

View File

@ -4,10 +4,16 @@ import com.badlogic.gdx.graphics.Texture;
public final class Textures {
public static Texture texbackground;
public static Texture cannon;
public static Texture cannon_body;
public static Texture cannon_barrel;
public static Texture cannon_hearth;
public static Texture cannon_bullet;
public static void init() {
texbackground = new Texture("level_background.png");
cannon = new Texture("cannon.png");
cannon_body = new Texture("cannon_body.png");
cannon_barrel = new Texture("cannon_barrel.png");
}
}

View File

@ -0,0 +1,12 @@
package de.samdev.cannonshooter;
public final class ZLayers {
// Higher Number => in front
public final static int LAYER_CANNON_BULLET = 4;
public final static int LAYER_CANNON_HEARTH = 3;
public final static int LAYER_CANNON_BODY = 2;
public final static int LAYER_CANNON_BARREL = 1;
}

View File

@ -5,13 +5,25 @@ import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometry
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
import de.samdev.absgdx.framework.layer.GameLayer;
import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.ZLayers;
public class Cannon extends Entity {
private CannonBarrel barrel;
public Cannon(float x, float y) {
super(Textures.cannon, 1, 1);
super(Textures.cannon_body, 2, 2);
setPosition(x, y);
setZLayer(ZLayers.LAYER_CANNON_BODY);
}
@Override
public void onLayerAdd(GameLayer layer) {
barrel = new CannonBarrel(this);
layer.addEntity(barrel);
}
@Override
@ -54,10 +66,4 @@ public class Cannon extends Entity {
}
@Override
public void onLayerAdd(GameLayer layer) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,73 @@
package de.samdev.cannonshooter.entities;
import de.samdev.absgdx.framework.entities.Entity;
import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner;
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
import de.samdev.absgdx.framework.layer.GameLayer;
import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.ZLayers;
public class CannonBarrel extends Entity {
private float rotation = 0;
public CannonBarrel(Cannon owner) {
super(Textures.cannon_barrel, 4, 2);
setPosition(owner.getPositionX() - 1, owner.getPositionY());
setZLayer(ZLayers.LAYER_CANNON_BARREL);
}
@Override
public void onActiveCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub
}
@Override
public void onPassiveCollide(CollisionGeometryOwner activeCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub
}
@Override
public void onActiveMovementCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub
}
@Override
public void onPassiveMovementCollide(CollisionGeometryOwner activeCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub
}
@Override
public boolean canCollideWith(CollisionGeometryOwner other) {
return false;
}
@Override
public boolean canMoveCollideWith(CollisionGeometryOwner other) {
return false;
}
@Override
public void beforeUpdate(float delta) {
rotation += 1;
rotation = (rotation + 1) % 360;
}
@Override
public float getTextureRotation() {
return rotation;
}
@Override
public void onLayerAdd(GameLayer layer) {
// TODO Auto-generated method stub
}
}

View File

@ -1,7 +1,5 @@
package de.samdev.cannonshooter.level;
import java.util.Random;
import com.badlogic.gdx.math.Vector2;
import de.samdev.absgdx.framework.AgdxGame;
@ -15,30 +13,25 @@ import de.samdev.cannonshooter.framework.TileAlignedBackground;
public class StandardLevel extends GameLayer {
public StandardLevel(AgdxGame owner) {
super(owner, TileMap.createEmptyMap(32, 32));
super(owner, TileMap.createEmptyMap(32, 20));
addBackground(new TileAlignedBackground(Textures.texbackground, 1));
setMapScaleResolver(new ShowCompleteMapScaleResolver());
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
Random R = new Random(80085);
for (int i = 0; i < 24; i++) {
addEntity(new Cannon(R.nextInt(15)*2+1, R.nextInt(15)*2+1));
}
addEntity(new Cannon(10, 10));
}
@Override
public void onResize() {
super.onResize();
// Center Map
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
}
@Override
public void onUpdate(float arg0) {
//setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
//
}
}

BIN
data/cannon_sketch.pdn Normal file

Binary file not shown.

Binary file not shown.