Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package RedHazard;
- import java.awt.Color;
- import java.awt.Graphics;
- public class Ship
- {
- public int x, y, width = 35, height = 35;
- public int score;
- public Ship(Redhazard a)
- {
- this.x = 0;
- this.y = 600;
- }
- public void render(Graphics g)
- {
- g.setColor(Color.BLUE);
- g.fillRect(x, y, width, height);
- }
- public void move(boolean left)
- {
- int speed = 10;
- if(left)
- {
- if(x - speed > 0)
- {
- x-=speed;
- }
- else
- {
- x = 0;
- }
- }
- else
- {
- if(x + width + speed < 700)
- {
- x += speed;
- }
- else
- {
- x = 700 - width;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment