Skip to content

Instantly share code, notes, and snippets.

@CoryNelson
Created October 16, 2012 09:14
Show Gist options
  • Select an option

  • Save CoryNelson/3898228 to your computer and use it in GitHub Desktop.

Select an option

Save CoryNelson/3898228 to your computer and use it in GitHub Desktop.
package cg.objects;
import cg.input.Input;
import java.awt.*;
/**
* User: Cory
* Date: 16/10/12
* Time: 10:03
*/
public class Player extends Rectangle {
private double gravity = 0;
public Player() {
setSize(60, 32);
}
public void process(Input i) {
gravity += (i.isMouseDown(1)) ? (-0.3) : (0.4);
y+=gravity;
}
public void render(Graphics g) {
g.setColor(Color.CYAN);
g.fillRect(x, y, width, height);
g.setColor(Color.WHITE);
g.drawRect(x, y, width, height);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment