Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x = 200;
- int y = 0;
- int planeDirection = 0;
- void setup() {
- size(512, 768);
- }
- void Movement() {
- if (key == CODED) {
- if (keyCode == LEFT) {
- planeDirection -= 1;
- }
- if (keyCode == RIGHT) {
- planeDirection += 1;
- }
- }
- }
- void draw() {
- drawBackground();
- Movement();
- if (planeDirection == 0) {
- drawSouth();
- }
- if (planeDirection == -1) {
- drawSouthWest();
- }
- if (planeDirection == -2) {
- drawWest();
- }
- if (planeDirection == +1) {
- drawSouthEast();
- }
- if (planeDirection == +2) {
- drawEast();
- }
- }
- void drawSouth() {
- y+=4;
- triangle(x - 10, y - 10, x + 10, y - 10, x, y + 10);
- }
- void drawSouthWest() {
- y+=3;
- x-=1;
- triangle(x, y - 10, x + 10, y + 2, x - 8, y + 8);
- }
- void drawWest() {
- y+=2;
- x-=2;
- triangle(x+10, y-10, x+10, y+10, x-10, y);
- }
- void drawSouthEast() {
- y+=3;
- x+=3;
- triangle(x, y - 10, x - 10, y + 4, x + 8, y + 8);
- }
- void drawEast() {
- y+=2;
- x+=2;
- triangle(x-10, y-10, x-10, y+10, x+10, y);
- }
- void drawBackground() {
- background(80, 60, 20);
- stroke(120, 120, 0);
- for (int Pineapple = 15; Pineapple < height; Pineapple += 15) {
- line(0, Pineapple, width, Pineapple);
- }
- for (int lineY = 0; lineY < height; lineY += 30) {
- for (int lineX = 0; lineX < width; lineX += 35) {
- line(lineX, lineY, lineX, lineY+15);
- line(lineX +15, lineY +15, lineX +15, lineY +30);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement