[alienbloodbath commit] r72 - in trunk: . content_package src/android/com/abb

1 view
Skip to first unread message

codesite...@google.com

unread,
Feb 7, 2009, 2:32:37 PM2/7/09
to alien-blood-b...@googlegroups.com
Author: matt.burkhart
Date: Sat Feb 7 10:26:06 2009
New Revision: 72

Added:
trunk/icon.svg
Modified:
trunk/content_package/jump.humanoid.animation
trunk/src/android/com/abb/ArticulatedEntity.java
trunk/src/android/com/abb/Avatar.java
trunk/src/android/com/abb/Entity.java
trunk/src/android/com/abb/Fire.java
trunk/src/android/com/abb/GameState.java
trunk/src/android/com/abb/Map.java
trunk/src/android/com/abb/Weapon.java

Log:
Generic weapons code development.

Modified: trunk/content_package/jump.humanoid.animation
==============================================================================
--- trunk/content_package/jump.humanoid.animation (original)
+++ trunk/content_package/jump.humanoid.animation Sat Feb 7 10:26:06 2009
@@ -18,5 +18,5 @@
arm_r 0.0 140
arm_l 0.0 135

-farm_r 0.0 -90
+farm_r 0.0 -95
farm_l 0.0 -90

Added: trunk/icon.svg
==============================================================================
--- (empty file)
+++ trunk/icon.svg Sat Feb 7 10:26:06 2009
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="77.866684"
+ height="77.866684"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="button.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/burkhart/Desktop/button.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ version="1.0">
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="9.2085798"
+ inkscape:cx="185.65595"
+ inkscape:cy="376.39301"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="839"
+ inkscape:window-height="1026"
+ inkscape:window-x="89"
+ inkscape:window-y="63" />
+ <defs
+ id="defs4">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient3484">
+ <stop
+ style="stop-color:#800000;stop-opacity:1;"
+ offset="0"
+ id="stop3486" />
+ <stop
+ style="stop-color:#800000;stop-opacity:0;"
+ offset="1"
+ id="stop3488" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient3306">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop3308" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop3310" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient3293">
+ <stop
+ style="stop-color:#c8c8c8;stop-opacity:1;"
+ offset="0"
+ id="stop3295" />
+ <stop
+ style="stop-color:#000000;stop-opacity:1"
+ offset="1"
+ id="stop3297" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3283">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop3285" />
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="1"
+ id="stop3287" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3293"
+ id="linearGradient3299"
+ x1="253.70647"
+ y1="358.6004"
+ x2="253.70647"
+ y2="389.62317"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3306"
+ id="linearGradient3316"
+ gradientUnits="userSpaceOnUse"
+ x1="269.42603"
+ y1="296.73862"
+ x2="269.42603"
+ y2="351.57248" />
+ <inkscape:perspective
+ id="perspective3473"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3484"
+ id="linearGradient3490"
+ x1="306.34872"
+ y1="410.41904"
+ x2="268.32932"
+ y2="362.52921"
+ gradientUnits="userSpaceOnUse" />
+ <filter
+ inkscape:collect="always"
+ id="filter3644"
+ x="-0.18763675"
+ width="1.3752735"
+ y="-0.20056684"
+ height="1.4011337">
+ <feGaussianBlur
+ inkscape:collect="always"
+ stdDeviation="4.8888169"
+ id="feGaussianBlur3646" />
+ </filter>
+ </defs>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-218.24605,-304.03778)">
+ <rect
+
style="fill:#c8c8c8;fill-opacity:1;stroke-width:1.60000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect3281"
+ width="77.866684"
+ height="77.866684"
+ x="218.24605"
+ y="304.03778"
+ ry="11.332709" />
+ <rect
+ ry="11.332709"
+ y="304.03778"
+ x="218.24605"
+ height="77.866684"
+ width="77.866684"
+ id="rect3291"
+
style="fill:url(#linearGradient3299);fill-opacity:1;stroke-width:1.60000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
/>
+ <image
+ y="320.65878"
+ x="221.70648"
+ id="image3475"
+ height="70.580284"
+ width="70.580284"
+
sodipodi:absref="/home/burkhart/programming/alienbloodbath/content_package/The_Second_Wave/hopper.png"
+
xlink:href="/home/burkhart/programming/alienbloodbath/content_package/The_Second_Wave/hopper.png"
/>
+ <path
+
style="opacity:1;fill:url(#linearGradient3316);fill-opacity:1;stroke-width:1.60000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+ d="M 228.65625,306.09375 C 221.81211,306.50655 218.81554,314.40083
220.25,320.375 C 219.88031,324.75064 219.60847,329.26614 224.1875,331.25 C
244.61659,345.21341 274.00267,345.04485 294.125,330.75 C
292.92953,323.28102 297.35304,312.83501 289.96875,307.59375 C
283.31033,303.96063 275.01621,307.05427 267.78125,306.03125 C
254.74102,306.07551 241.6906,305.94442 228.65625,306.09375 z"
+ id="rect3301" />
+ <path
+
style="fill:url(#linearGradient3490);fill-opacity:1;stroke-width:1.60000002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;filter:url(#filter3644)"
+ d="M 278.375,323.40625 C 253.65507,323.40625 233.59375,345.01926
233.59375,371.65625 C 233.59375,375.1754 233.96016,378.60057
234.625,381.90625 L 284.78125,381.90625 C 291.05957,381.90625
296.125,376.84083 296.125,370.5625 L 296.125,327.375 C 290.68296,324.83923
284.67799,323.40625 278.375,323.40625 z"
+ id="rect3479" />
+ </g>
+</svg>

Modified: trunk/src/android/com/abb/ArticulatedEntity.java
==============================================================================
--- trunk/src/android/com/abb/ArticulatedEntity.java (original)
+++ trunk/src/android/com/abb/ArticulatedEntity.java Sat Feb 7 10:26:06
2009
@@ -60,10 +60,9 @@
(tokens.length - 1) % kLineTokenCount, 0);

// Path names are expected to be relative to the path specified for the
- // entity file.
+ // entity definition file.
String uri_string = uri.toString();
- Log.d("ArtifulatedEnt::loadFromUri", "Found uri= " + uri_string);
- Log.d("ArticulatedEnt:Lload", "Index= " + uri_string.lastIndexOf("/"));
+ Log.d("ArtifulatedEntity::loadFromUri", "Found uri= " + uri_string);
String base_uri_string = uri_string.substring(0,
uri_string.lastIndexOf("/"));
mImageUri = Uri.parse(base_uri_string + "/" + tokens[0]);

@@ -133,7 +132,7 @@
}

/** Return the 3x3 transformation matrix used to draw child parts. In
other
- * words, the returned matrix transforms points into screen coordinates
with
+ * words, the returned matrix transforms points into *screen
coordinates* with
* the origin at the tip / end of the part. For example, multiplying by
the
* vector (0, 0, 1)^T will yield (x, y, w) screen coordinates at the tip
of
* the part. */

Modified: trunk/src/android/com/abb/Avatar.java
==============================================================================
--- trunk/src/android/com/abb/Avatar.java (original)
+++ trunk/src/android/com/abb/Avatar.java Sat Feb 7 10:26:06 2009
@@ -11,6 +11,7 @@

package android.com.abb;

+import android.graphics.Matrix;
import android.graphics.Rect;
import android.net.Uri;
import android.view.KeyEvent;
@@ -69,7 +70,7 @@
stepAnimation(time_step);
}

- // Update the equiped weapon instance.
+ // Update the equipped weapon instance.
if (mWeapon != null) {
mWeapon.x = x;
mWeapon.y = y;
@@ -88,8 +89,20 @@
mCanvasHeight = graphics.getHeight();

super.draw(graphics, center_x, center_y, zoom);
+
+ // The weapon must be drawn after the avatar's articulated entity. In
+ // addition to the fact that no z-buffer is used, the articulated
entity's
+ // draw method calculates the model's hand positions which we use to
draw
+ // the weapon on top of.
if (mWeapon != null) {
- mWeapon.draw(graphics, center_x, center_y, zoom);
+ super.getPartTransformation("farm_l").getValues(mArray9);
+ float hand_lx = mArray9[2];
+ float hand_ly = mArray9[5];
+ super.getPartTransformation("farm_r").getValues(mArray9);
+ float hand_rx = mArray9[2];
+ float hand_ry = mArray9[5];
+ mWeapon.draw(graphics, center_x, center_y, zoom,
+ hand_lx, hand_ly, hand_rx, hand_ry);
}
}

@@ -156,10 +169,15 @@
motion_event.recycle();
}

+ void setWeapon(Weapon weapon) {
+ mWeapon = weapon;
+ }
+
private int mCanvasWidth;
private int mCanvasHeight;
private GameState mGameState;
public Weapon mWeapon;
+ private float[] mArray9 = new float[9]; // To avoid allocations.

private static final float kAirAcceleration = 40.0f;
private static final float kAnimationStopThreshold = 40.0f;

Modified: trunk/src/android/com/abb/Entity.java
==============================================================================
--- trunk/src/android/com/abb/Entity.java (original)
+++ trunk/src/android/com/abb/Entity.java Sat Feb 7 10:26:06 2009
@@ -75,6 +75,11 @@
}
}

+ public boolean collidesWith(Entity entity) {
+ return (Math.abs(entity.x - x) < radius + entity.radius &&
+ Math.abs(entity.y - y) < radius + entity.radius);
+ }
+
@Override
public Object clone() {
try {

Modified: trunk/src/android/com/abb/Fire.java
==============================================================================
--- trunk/src/android/com/abb/Fire.java (original)
+++ trunk/src/android/com/abb/Fire.java Sat Feb 7 10:26:06 2009
@@ -39,13 +39,6 @@
}
}

- public void collideEntity(Entity entity) {
- if (Math.abs(entity.x - x) < radius + entity.radius &&
- Math.abs(entity.y - y) < radius + entity.radius) {
- entity.alive = false; // Anything which collides with fire dies.
- }
- }
-
private float mFrame = 0.0f;

private static final int kFrames = 13;

Modified: trunk/src/android/com/abb/GameState.java
==============================================================================
--- trunk/src/android/com/abb/GameState.java (original)
+++ trunk/src/android/com/abb/GameState.java Sat Feb 7 10:26:06 2009
@@ -107,6 +107,7 @@
if (avatar.alive) {
avatar.step(time_step);
map.collideEntity(avatar);
+ map.processTriggers(avatar);
if (Map.tileIsGoal(map.tileAt(avatar.x, avatar.y))) {
map.advanceLevel();
reset();
@@ -148,10 +149,14 @@

// Step the projectiles and collide them against the enemies.
for (int index = 0; index < projectiles.size(); ++index) {
- Fire projectile = (Fire)projectiles.get(index);
+ Entity projectile = projectiles.get(index);
projectile.step(time_step);
for (int enemy_index = 0; enemy_index < enemies.size();
++enemy_index) {
- projectile.collideEntity(enemies.get(enemy_index));
+ Enemy enemy = enemies.get(enemy_index);
+ if (projectile.collidesWith(enemy)) {
+ enemy.alive = false;
+ projectile.alive = false;
+ }
}
if (!projectile.alive) {
projectiles.remove(index);
@@ -222,6 +227,31 @@
return blood;
}

+ public Weapon createWeaponFromUri(Uri uri) {
+ Weapon weapon = mWeaponCache.get(uri);
+ if (weapon == null) {
+ weapon = new Weapon(this);
+ weapon.loadFromUri(uri);
+ mWeaponCache.put(uri, weapon);
+ }
+ return weapon;
+ }
+
+ public void createProjectile(float x, float y, float dx, float dy,
+ int image_handle, Rect image_rect,
+ boolean sprite_flipped_horizontal) {
+ Entity projectile = new Entity();
+ projectile.x = x;
+ projectile.y = y;
+ projectile.dx = dx;
+ projectile.dy = dy;
+ projectile.sprite_image = image_handle;
+ projectile.sprite_rect = image_rect;
+ projectile.sprite_flipped_horizontal = sprite_flipped_horizontal;
+ projectile.radius = Math.min(image_rect.width(), image_rect.height());
+ projectiles.add(projectile);
+ }
+
public Entity createFireProjectile(float x, float y, float dx, float dy)
{
Entity fire = new Fire();
fire.sprite_image = misc_sprites;
@@ -229,7 +259,7 @@
fire.y = y;
fire.dx = dx;
fire.dy = dy;
- fire.ddy = -50.0f; // Slight up draft.
+ fire.ddy = -50.0f; // Slight "up draft".
projectiles.add(fire);
return fire;
}
@@ -289,10 +319,11 @@
private Vibrator mVibrator;
private float mViewX = 0.0f;
private float mViewY = 0.0f;
+ private TreeMap<Uri, Weapon> mWeaponCache = new TreeMap<Uri, Weapon>();
private float mZoom = kGroundZoom;

private static final float kAirZoom = 0.6f;
- private static final int kBloodBathSize = 10; // Number of blood
particles.
+ private static final int kBloodBathSize = 20; // Number of blood
particles.
private static final float kBloodBathVelocity = 60.0f;
private static final float kDeathTimer = 4.0f;
private static final float kDeathZoom = 1.5f;

Modified: trunk/src/android/com/abb/Map.java
==============================================================================
--- trunk/src/android/com/abb/Map.java (original)
+++ trunk/src/android/com/abb/Map.java Sat Feb 7 10:26:06 2009
@@ -424,6 +424,26 @@
}
}

+ void processTriggers(Avatar avatar) {
+ int tile_index = indexAt(avatar.x, avatar.y);
+ if (tile_index < 0) {
+ return; // Tile out of bounds.
+ }
+
+ String trigger = mTriggers[tile_index];
+ if (trigger == null) {
+ return; // No trigger at the avatar's location.
+ }
+
+ if (trigger.startsWith("weapon=")) {
+ Uri weapon_uri = Uri.withAppendedPath(mBaseUri,
trigger.substring(7));
+ Weapon weapon = mGameState.createWeaponFromUri(weapon_uri);
+ avatar.setWeapon(weapon);
+ mTriggers[tile_index] = null;
+ mTiles[tile_index] = 0;
+ }
+ }
+
public void loadStateBundle(Bundle saved_instance_state) {
mBaseUri = Uri.parse(saved_instance_state.getString("mBaseUri"));
mLevelOffset = saved_instance_state.getInt("mLevelOffset");

Modified: trunk/src/android/com/abb/Weapon.java
==============================================================================
--- trunk/src/android/com/abb/Weapon.java (original)
+++ trunk/src/android/com/abb/Weapon.java Sat Feb 7 10:26:06 2009
@@ -13,6 +13,7 @@

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Matrix;
import android.graphics.Rect;
import android.net.Uri;
import android.util.Log;
@@ -42,13 +43,14 @@
parameters.put(kParameterProjectileRectLeft, new Integer(-1));
parameters.put(kParameterProjectileRectRight, new Integer(-1));
parameters.put(kParameterProjectileRectTop, new Integer(-1));
+ parameters.put(kParameterSpread, new Float(kDefaultSpread));
parameters.put(kParameterSprite, "none");
parameters.put(kParameterWeaponRectBottom, new Integer(-1));
parameters.put(kParameterWeaponRectLeft, new Integer(-1));
parameters.put(kParameterWeaponRectRight, new Integer(-1));
parameters.put(kParameterWeaponRectTop, new Integer(-1));
parameters.put(kParameterVelocity, new Float(kDefaultVelocity));
- parameters.put(kParameterVibration, new Float(kDefaultVibration));
+ parameters.put(kParameterVibration, new Integer(kDefaultVibration));

// Given a fully-specified default weapon parameters map, we can parse
and
// merge in the user defined values. Note that the following method
rejects
@@ -66,12 +68,29 @@
Content.assertIntegerNotNone(parameters, kParameterWeaponRectRight);
Content.assertIntegerNotNone(parameters, kParameterWeaponRectTop);

+ // Path names are expected to be relative to the path specified for the
+ // weapon definition file.
+ String uri_string = uri.toString();
+ String base_uri_string =
+ uri_string.substring(0, uri_string.lastIndexOf("/") + 1);
+
// Now that the user defined weapon parameters have been parsed and
merged,
// we can initialize the weapon instance state accordingly.
mDelay = ((Float)parameters.get(kParameterDelay)).floatValue();
mSpread = ((Float)parameters.get(kParameterSpread)).floatValue();
mVelocity = ((Float)parameters.get(kParameterVelocity)).floatValue();
mVibration = ((Integer)parameters.get(kParameterVibration)).intValue();
+ mSpriteUri = Uri.parse(base_uri_string +
(String)parameters.get(kParameterSprite));
+ sprite_rect = new Rect(
+ ((Integer)parameters.get(kParameterWeaponRectLeft)).intValue(),
+ ((Integer)parameters.get(kParameterWeaponRectTop)).intValue(),
+ ((Integer)parameters.get(kParameterWeaponRectRight)).intValue(),
+ ((Integer)parameters.get(kParameterWeaponRectBottom)).intValue());
+ mProjectileRect = new Rect(
+ ((Integer)parameters.get(kParameterProjectileRectLeft)).intValue(),
+ ((Integer)parameters.get(kParameterProjectileRectTop)).intValue(),
+
((Integer)parameters.get(kParameterProjectileRectRight)).intValue(),
+
((Integer)parameters.get(kParameterProjectileRectBottom)).intValue());
}

public void enableShooting(boolean shooting) {
@@ -85,49 +104,70 @@
// Update the shooting mechanism. The following is specialized for
running
// or standing on the ground versus jumping.
mCurrentDelay -= time_step;
- if (mShooting && mCurrentDelay < time_step) {
- mDelay = mDelay;
+ if (mShooting && mCurrentDelay < time_step && sprite_image != -1) {
+ mCurrentDelay = mDelay;
+ mPhase += 10.0f;
+
float shot_angle;
- float shot_distance = 64;
+ float shot_distance = sprite_rect.width() / 2;
float shot_velocity = mVelocity;
- float x_offset;
- float y_offset;
+ float x_offset = shot_distance;
+ float y_offset = 0.0f;

if (!has_ground_contact) {
shot_angle = mPhase;
- if (sprite_flipped_horizontal) {
- shot_angle = -mPhase;
- }
- mDelay -= 2.0f * time_step;
- mPhase += 45.0f * (float)Math.PI / 180.0f;
- shot_velocity *= 0.6f;
x_offset = shot_distance * (float)Math.cos(shot_angle);
y_offset = shot_distance * (float)Math.sin(shot_angle);
- } else if (sprite_flipped_horizontal) {
- shot_angle = mSpread * (float)Math.sin(mPhase) + (float)Math.PI;
- mPhase += 10.0f;
- x_offset = -0;
- y_offset = 0;
} else {
shot_angle = mSpread * (float)Math.sin(mPhase);
- mPhase += 10.0f;
- x_offset = 0;
- y_offset = 0;
}

float dx_offset = shot_velocity * (float)Math.cos(shot_angle);
float dy_offset = shot_velocity * (float)Math.sin(shot_angle);
- mGameState.createFireProjectile(
- x + x_offset, y + y_offset, dx + dx_offset, dy + dy_offset);
+
+ if (sprite_flipped_horizontal) {
+ x_offset *= -1.0f;
+ dx_offset *= -1.0f;
+ }
+
+ mGameState.createProjectile(x + x_offset, y + y_offset,
+ dx + dx_offset, dy + dy_offset,
+ sprite_image, mProjectileRect,
+ sprite_flipped_horizontal);
+
if (mVibration > 0) {
mGameState.vibrate(mVibration);
}
}
}

- @Override
+ /** Draw the weapon position given the positions of the owners "hand"
+ * positions. The coordinates are expected to be *screen coordinates*,
not
+ * world coordinates. */
public void draw(Graphics graphics, float center_x, float center_y,
- float zoom) {
+ float zoom, float hand_lx, float hand_ly, float hand_rx,
+ float hand_ry) {
+ // Load part image if it hasn't yet been loaded. This is necessary
since the
+ // graphics class must only be interacted with from the main thread.
This is
+ // a product of the lack of thread safety in OpenGL.
+ if (mSpriteUri != null) {
+ String image_path = Content.getTemporaryFilePath(mSpriteUri);
+ Bitmap image_bitmap = BitmapFactory.decodeFile(image_path);
+ sprite_image = graphics.loadImageFromBitmap(image_bitmap);
+ mSpriteUri = null;
+ }
+
+ // Note that the avatar hand coordinates are specified in screen
+ // coordinates, not world coordinates. They are set via the
+ // setHandsPositions method.
+ if (sprite_image != -1) {
+ mDrawingMatrix.setTranslate(hand_lx, hand_ly);
+ mDrawingMatrix.preRotate(
+ 57.2958f * (float)Math.atan2(hand_ry - hand_ly, hand_rx -
hand_lx));
+ mDrawingMatrix.preScale(sprite_rect.width(), sprite_rect.height());
+ graphics.drawImage(sprite_image, sprite_rect, mDrawingMatrix,
+ sprite_flipped_horizontal,
sprite_flipped_vertical);
+ }
}

@Override
@@ -136,11 +176,14 @@
}

private float mCurrentDelay;
- private GameState mGameState; // Needed for projectile instantiation.
- private boolean mShooting;
private float mDelay;
+ private static Matrix mDrawingMatrix = new Matrix();
+ private GameState mGameState; // Needed for projectile instantiation.
private float mPhase;
+ private Rect mProjectileRect;
+ private boolean mShooting;
private float mSpread;
+ private Uri mSpriteUri;
private float mVelocity;
private int mVibration;

Reply all
Reply to author
Forward
0 new messages