Android Open Source - linevslinerpg Item






From Project

Back to project page linevslinerpg.

License

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.

Java Source Code

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);
    
  }
}




Java Source Code List

com.jmpmain.lvslrpg.AudioPlayer.java
com.jmpmain.lvslrpg.GameSurface.java
com.jmpmain.lvslrpg.GameThread.java
com.jmpmain.lvslrpg.LineCanvas.java
com.jmpmain.lvslrpg.MainActivity.java
com.jmpmain.lvslrpg.MapGenerator.java
com.jmpmain.lvslrpg.Map.java
com.jmpmain.lvslrpg.OptionsAdapter.java
com.jmpmain.lvslrpg.entities.AILineEntity.java
com.jmpmain.lvslrpg.entities.Entity.java
com.jmpmain.lvslrpg.entities.Item.java
com.jmpmain.lvslrpg.entities.LineEntity.java
com.jmpmain.lvslrpg.entities.PlayerLineEntity.java
com.jmpmain.lvslrpg.particles.Blood.java
com.jmpmain.lvslrpg.particles.Bomb.java
com.jmpmain.lvslrpg.particles.Energy.java
com.jmpmain.lvslrpg.particles.Heal.java
com.jmpmain.lvslrpg.particles.ItemParticle.java
com.jmpmain.lvslrpg.particles.Particle.java
com.jmpmain.lvslrpg.particles.Smoke.java