Advertisement
pseudocreator

jgd Player.java

May 18th, 2014
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package com.game.src.main;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.image.BufferedImage;
  5.  
  6. public class Player {
  7.    
  8.     private double x;
  9.     private double y;
  10.    
  11.     private double velX = 0;
  12.     private double velY = 0;
  13.    
  14.     private BufferedImage player;
  15.    
  16.     public Player(double x,double y, Game game){
  17.        
  18.         this.x = x;
  19.         this.y = y;
  20.        
  21.         SpriteSheet ss = new SpriteSheet(game.getSpriteSheet());
  22.        
  23.         player = ss.grabImage(1, 1, 32, 32);
  24.        
  25.     }
  26.    
  27.     public void tick(){
  28.         x+= velX;
  29.         y+= velY;
  30.    
  31.     }
  32.    
  33.     public void render(Graphics g){
  34.         g.drawImage(player, (int)x, (int)y, null);
  35.     }
  36.    
  37.     public double getX(){
  38.         return x;
  39.     }
  40.     public double getY(){
  41.         return y;
  42.     }
  43.    
  44.     public void setX(double x){
  45.         this.x = x;
  46.     }
  47.     public void setY(double y){
  48.         this.y = y;
  49.     }
  50.     public void setVelX(double velX){
  51.         this.velX = velX;
  52.     }
  53.     public void setVelY(double velY){
  54.         this.velY = velY;
  55.     }
  56.    
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement