Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Toolkit;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.util.ArrayList;
- /*
- *
- *
- * @Author sp0wner 2012
- *
- * World.java
- *
- * World - Used to display the world of the game
- *
- * -Initialises map
- * -Draws the map on the screen using the draw() function
- * -Draws elements on the map such as obstacles,trees etc
- *
- */
- public class World {
- // holds the map object
- private Map map;
- private char[][] map2d;
- // map size
- private int mHeight = 100, mWidth = 100;
- // screen width and height
- private int pWidth, pHeight;
- // How much to move when arrows are pressed
- private int xStep = 30, yStep = 30;
- private Floor floor; // holds the floor
- //private TiledSprite sprite;
- /**
- * @see Constructor of the World class
- * @param pWidth
- * -panel Width
- * @param pHeight
- * - panel Height
- */
- public World(int pWidth, int pHeight) {
- this.pWidth = pWidth;
- this.pHeight = pHeight;
- initMap();
- initFloor();
- //initSprite();
- }// end of constructor
- public void initFloor(){
- floor = new Floor(map2d,map.getWidth(),map.getHeight(),pWidth, pHeight);
- }
- /**
- * @see Initiates map object
- */
- public void initMap()
- {
- map = new Map(mHeight, mWidth);
- map2d=map.getMap();
- }
- public void draw(Graphics g){
- floor.draw(g);
- //sprite.draw(g);
- }
- boolean sthIsSelected=false;
- public void mousePressed(MouseEvent e){
- if(e.getButton()==MouseEvent.BUTTON1){
- //sprite.select(e.getX(), e.getY());
- //if(sprite.getSelected())
- //sthIsSelected=true;
- }
- if(e.getButton()==MouseEvent.BUTTON3 && sthIsSelected){
- //sprite.moveTo(e.getX(),e.getY());
- }
- }
- /**
- * @see This methods is responsible for moving the camera arroung
- * @param keycode
- * - They key code of the button pressed
- */
- public void moveCamera(int keycode) {
- floor.moveCamera(keycode,xStep,yStep);
- //sprite.moveCamera(keycode,xStep,yStep);
- }//end of moveCamera()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement