Back to project page linevslinerpg.
The source code is released under:
Apache License
If you think the Android project linevslinerpg listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jmpmain.lvslrpg.entities; //from w w w .ja v a 2s . c o m import com.jmpmain.lvslrpg.GameSurface; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; public class Item extends Entity { public int x; public int y; public int width; public int height; private Bitmap icon; public boolean pickup; public enum ItemType{ Coin(0), Potion(1), Teleport_Scroll(2), Speed_Scroll(3), Shield_Scroll(4), Bomb(5), Chest(6); public final int value; private ItemType(int v){ value = v; } } public ItemType type; public Item(ItemType t, int tx, int ty){ type = t; x = tx; y = ty; width = 32; height = 32; icon = GetItemIcon(t); if(t == ItemType.Coin || t == ItemType.Chest){ pickup = false; }else{ pickup = true; } } public static Bitmap GetItemIcon(ItemType type){ if(type == ItemType.Coin) return GameSurface.coin; else if(type == ItemType.Potion) return GameSurface.potion; else if(type == ItemType.Teleport_Scroll) return GameSurface.teleport_scroll; else if(type == ItemType.Speed_Scroll) return GameSurface.speed_scroll; else if(type == ItemType.Shield_Scroll) return GameSurface.shield_scroll; else if(type == ItemType.Bomb) return GameSurface.bomb; else if(type == ItemType.Chest) return GameSurface.chest; return null; } @Override public void update(long time) { } @Override public void draw(Canvas canvas) { Paint p = new Paint(); //Draw coin. canvas.drawBitmap(icon, new Rect(0, 0, 32, 32), new Rect(x, y, x + 32, y + 32), p); } }