Results 1 to 3 of 3
  1. #1
    InfiniteCoder is offline Member
    Join Date
    Mar 2013
    Posts
    5
    Rep Power
    0

    Question Help With Block Class?

    I need help with getting an ID by name, vice versa. The code for the block class so far is below.
    Java Code:
    package net.infinitecoder.game.main;
    
    public class Block {
    	public String name;
    	public int[] location;
    	public int ID;
    	public boolean collidable;
    	public float lightEmitted = 0f;
    	
    	public static Block Air = new Block("Air", false, -1, -1, 0);
    	public static Block Grass = new Block("Grass", true, 0, 0, 1);
    	public static Block Dirt = new Block("Dirt", true, 1, 0, 2);
    	public static Block Stone = new Block("Stone", true, 2, 0, 3);
    	public static Block Gold = new Block("Gold", true, 0.2f, 2, 0, 4);
    	
    	/* Normal, Non-Special Block 
    	X & Y location for spritesheet */
    	public Block(String name, boolean canCollide, int x, int y, int ID) {
    		this.name = name;
    		this.collidable = canCollide;
    		int[] location = {x, y};
    		this.location = location;
    		this.ID = ID;
    	}
    	
    	/* Special, Light-Emitting Block */
    	public Block(String name, boolean canCollide, float lightEmitted, int x, int y, int ID) {
    		this.name = name;
    		this.collidable = canCollide;
    		this.lightEmitted = lightEmitted;
    		int[] location = {x, y};
    		this.location = location;
    		this.ID = ID;
    	}
    	
    	public int getID() { return ID;}
    	public String getName() {return name;}
    	public boolean isCollidable() { return collidable;}
    	public float getLightEmitted() { return lightEmitted;}
    }
    Last edited by InfiniteCoder; 03-02-2013 at 06:35 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Help With Block Class?

    1. Check the dates and don't post to old dead threads.
    2. Offer advice, not solutions, and avoid external links.

    I've removed the links from your other posts.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

Similar Threads

  1. Try Catch Block
    By Jackbower in forum New To Java
    Replies: 3
    Last Post: 05-06-2012, 07:00 AM
  2. Only one wall block?
    By werner291 in forum New To Java
    Replies: 4
    Last Post: 09-28-2011, 01:47 PM
  3. block url
    By thedevilz in forum New To Java
    Replies: 1
    Last Post: 09-16-2010, 10:55 PM
  4. if block with logical or
    By Ranu in forum New To Java
    Replies: 6
    Last Post: 07-01-2010, 08:11 AM
  5. Someone plz help... how to block inputs
    By waklo99 in forum New To Java
    Replies: 4
    Last Post: 03-15-2010, 06:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •