Permalink
Browse files

Added some item graphics

  • Loading branch information...
1 parent 7003018 commit eb7aa8e9a3c321d35cd829ef001f0512754c2186 @noonat committed May 2, 2011
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -33,7 +33,7 @@ package {
add(this.level = level);
level.createEntities(this);
- _vendorMenu = new VendorMenu(itemClasses, FP.width / 2, FP.height - 16);
+ _vendorMenu = new VendorMenu(itemClasses, FP.width / 2, FP.height - 48);
_vendorMenu.onItem.add(onVendorItem);
_vendorMenu.show();
add(_vendorMenu);
View
@@ -8,9 +8,11 @@ package {
protected var _inventory:Inventory;
function Item() {
- super(0, 0, Image.createRect(8, 8, 0x00ffff));
- (graphic as Image).centerOO();
- setHitbox(8, 8, 4, 4);
+ super(0, 0);
+ setHitbox(Level.TILE, Level.TILE);
+ centerOrigin();
+ ++originX;
+ ++width;
layer = Layers.ITEMS;
type = 'item';
itemName = 'Item';
View
@@ -1,6 +1,7 @@
package {
import flash.geom.Rectangle;
import net.flashpunk.FP;
+ import net.flashpunk.graphics.Text;
import net.flashpunk.Signal;
import net.flashpunk.World;
import net.flashpunk.utils.Draw;
@@ -11,6 +12,7 @@ package {
protected var _buttons:Vector.<Button>;
protected var _items:Vector.<Item>;
protected var _rect:Rectangle;
+ protected var _text:Text;
function VendorMenu(itemClasses:Array, x:Number, y:Number) {
super(x, y, 1, 1);
@@ -22,9 +24,19 @@ package {
_buttons = new Vector.<Button>();
_items = new Vector.<Item>();
for each (var cls:Class in itemClasses) {
- _items.push(new cls() as Item);
+ var item:Item = new cls() as Item;
+ item.layer = Layers.MENU_BUTTON;
+ _items.push(item);
}
createButtons();
+
+ _text = new Text('choose');
+ _text.size = 8;
+ _text.alpha = 0.3;
+ _text.x = 0;
+ _text.y = Level.TILE * 2;
+ _text.centerOO();
+ graphic = _text;
}
override public function added():void {
@@ -59,7 +71,7 @@ package {
item.x += _rect.x;
item.y += _rect.y;
}
- _rect.inflate(Level.TILE, Level.TILE);
+ _rect.inflate(Level.TILE / 2, Level.TILE / 2);
setHitbox(_rect.width, _rect.height);
}
@@ -86,7 +98,12 @@ package {
}
override public function render():void {
- Draw.rect(_rect.x, _rect.y, _rect.width, _rect.height, 0xff0000, 0.1);
+ Draw.rect(_rect.x, _rect.y, _rect.width, _rect.height, 0x111111);
+ for each (var item:Item in _items) {
+ Draw.rect(
+ item.x - item.originX, item.y - item.originY,
+ item.width, item.height, 0xB294BB, 0.3);
+ }
super.render();
}
View
@@ -1,8 +1,10 @@
package {
import flash.display.BitmapData;
+ import flash.geom.Point;
import net.flashpunk.components.Health;
import net.flashpunk.Entity;
import net.flashpunk.FP;
+ import net.flashpunk.Graphic;
import net.flashpunk.graphics.Image;
public class Warrior extends Monster {
@@ -12,6 +14,8 @@ package {
protected var _boon:Item;
protected var _wanderX:Number = 0;
protected var _wanderY:Number = 0;
+ private var _camera:Point = new Point();
+ private var _point:Point = new Point();
function Warrior() {
super();
@@ -56,6 +60,24 @@ package {
_boon = null;
}
+ override public function render():void {
+ super.render();
+ if (_health.alive && _boon !== null) {
+ var g:Graphic = _boon.graphic;
+ if (g && g.visible) {
+ if (g.relative) {
+ _point.x = x - 2;
+ _point.y = y - 1;
+ } else {
+ _point.x = _point.y = 0;
+ }
+ _camera.x = FP.camera.x;
+ _camera.y = FP.camera.y;
+ g.render(renderTarget ? renderTarget : FP.buffer, _point, _camera);
+ }
+ }
+ }
+
override protected function think():void {
if (_boon !== null) {
super.think();
View
@@ -1,7 +1,20 @@
package items {
+ import flash.display.BitmapData;
+ import net.flashpunk.graphics.Image;
+
public class WoodenShield extends Item {
+ [Embed(source="../../assets/wooden_shield.png")]
+ static protected const IMAGE:Class;
+
+ protected var _image:Image;
+
function WoodenShield() {
super();
+ Assets.getBitmap(IMAGE, function(bitmap:BitmapData):void {
+ _image = new Image(bitmap);
+ _image.centerOO();
+ graphic = _image;
+ });
type = 'shield';
itemName = 'Wooden Shield';
}
View
@@ -1,7 +1,20 @@
package items {
+ import flash.display.BitmapData;
+ import net.flashpunk.graphics.Image;
+
public class WoodenSword extends Item {
+ [Embed(source="../../assets/wooden_sword.png")]
+ static protected const IMAGE:Class;
+
+ protected var _image:Image;
+
function WoodenSword() {
super();
+ Assets.getBitmap(IMAGE, function(bitmap:BitmapData):void {
+ _image = new Image(bitmap);
+ _image.centerOO();
+ graphic = _image;
+ });
type = 'sword';
stats.damage = 1;
itemName = 'Wooden Sword';

0 comments on commit eb7aa8e

Please sign in to comment.