Progress on CannonHearth

This commit is contained in:
Mike Schwörer 2015-09-17 16:11:58 +02:00
parent aa006a5c0b
commit 9c63975f2c
5 changed files with 30 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

@ -1,5 +1,9 @@
package de.samdev.cannonshooter.entities; package de.samdev.cannonshooter.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import de.samdev.absgdx.framework.entities.Entity; import de.samdev.absgdx.framework.entities.Entity;
import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner; import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner;
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry; import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
@ -10,7 +14,6 @@ import de.samdev.cannonshooter.ZLayers;
public class CannonBarrel extends Entity { public class CannonBarrel extends Entity {
private static final float ANIMATION_DURATION = 1000; private static final float ANIMATION_DURATION = 1000;
private float rotation = 0; private float rotation = 0;
public CannonBarrel(Cannon owner) { public CannonBarrel(Cannon owner) {

View File

@ -1,5 +1,9 @@
package de.samdev.cannonshooter.entities; package de.samdev.cannonshooter.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import de.samdev.absgdx.framework.entities.Entity; import de.samdev.absgdx.framework.entities.Entity;
import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner; import de.samdev.absgdx.framework.entities.colliosiondetection.CollisionGeometryOwner;
import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry; import de.samdev.absgdx.framework.entities.colliosiondetection.geometries.CollisionGeometry;
@ -8,6 +12,8 @@ import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.ZLayers; import de.samdev.cannonshooter.ZLayers;
public class CannonHearth extends Entity { public class CannonHearth extends Entity {
private static final Color COLOR_NEUTRAL = new Color(0.75f, 0.75f, 0.75f, 1f);
private float rotation = 0; private float rotation = 0;
public CannonHearth(Cannon owner) { public CannonHearth(Cannon owner) {
@ -18,6 +24,19 @@ public class CannonHearth extends Entity {
setZLayer(ZLayers.LAYER_CANNON_HEARTH); setZLayer(ZLayers.LAYER_CANNON_HEARTH);
} }
@Override
public void render(SpriteBatch sbatch, ShapeRenderer srenderer) {
sbatch.setColor(COLOR_NEUTRAL);
renderTexture(sbatch, Textures.cannon_hearth[63], 0, 0);
sbatch.setColor(Color.RED);
renderTexture(sbatch, Textures.cannon_hearth[(int)(rotation/4f) % 64], 0, 0);
sbatch.setColor(Color.WHITE);
}
@Override @Override
public void onActiveCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) { public void onActiveCollide(CollisionGeometryOwner passiveCollider, CollisionGeometry myGeo, CollisionGeometry otherGeo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -54,12 +73,12 @@ public class CannonHearth extends Entity {
@Override @Override
public void beforeUpdate(float delta) { public void beforeUpdate(float delta) {
rotation = (rotation + 360 - delta / 8) % 360; rotation = (rotation + 360 + delta / 8) % 360;
} }
@Override @Override
public float getTextureRotation() { public float getTextureRotation() {
return rotation; return 0;//rotation;
} }
@Override @Override

View File

@ -11,8 +11,8 @@ void Main()
Image output = new Bitmap(input.Width * 8, input.Height * 8, PixelFormat.Format32bppArgb); Image output = new Bitmap(input.Width * 8, input.Height * 8, PixelFormat.Format32bppArgb);
var b1 = new SolidBrush(Color.Black); var b1 = new SolidBrush(Color.Transparent);
var b2 = new SolidBrush(Color.Magenta); var b2 = new SolidBrush(Color.White);
using (Graphics g = Graphics.FromImage(output)) using (Graphics g = Graphics.FromImage(output))
{ {
@ -20,7 +20,7 @@ void Main()
{ {
for (int y = 0; y < 8; y++) for (int y = 0; y < 8; y++)
{ {
var rad = ((y*8 + x) / 64.0) * 2 * Math.PI; var rad = ((y*8 + x) / 63.0) * 2 * Math.PI;
for (int ix = 0; ix < input.Width; ix++) for (int ix = 0; ix < input.Width; ix++)
{ {
@ -31,7 +31,7 @@ void Main()
if (input.GetPixel(ix, iy).A > 0) if (input.GetPixel(ix, iy).A > 0)
{ {
if (GetAngle(new Vector2(ix - input.Width / 2f, iy - input.Height / 2f)) < rad) if (GetAngle(new Vector2(ix - input.Width / 2f, iy - input.Height / 2f)) >= rad)
{ {
g.FillRectangle(b1, dx, dy, 1, 1); g.FillRectangle(b1, dx, dy, 1, 1);
} }

Binary file not shown.