Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage // processing image
- player, // žaidėjas
- donut; // spurga
- int
- playerX,
- playerY,
- playerSize,
- playerStep,
- donutX,
- donutY,
- donutSize,
- score = 0;
- void setup () {
- size (1200, 800);
- player = loadImage ("data/player.png");
- donut = loadImage ("data/donut.png");
- // imageMode (CORNER); - standartiškai
- // imageMode (CENTER); - galima pasidaryti ir taip
- // pasistatau žaidėją maždaug per vidurį
- playerX = width / 2;
- playerY = height / 2;
- playerSize = height / 5; // height * 0.2 - 160
- playerStep = height / 50; // 800 / 50 = 16
- donutX = donutY = donutSize = height / 7;
- }
- void player () {
- // jeigu paspaustas 'a' klavišas IR ...
- // judėti į kairę
- // jeigu paspaustas 'd' klavišas IR ...
- // judėti į dešinę
- // jeigu paspaustas 'w' klavišas IR ...
- // judėti į viršų
- // jeigu paspaustas 's' klavišas IR ...
- // judėti į apačią
- if (keyPressed && key == 'a')
- playerX -= playerStep;
- //playerX = playerX - playerStep;
- else if (keyPressed && key == 'd')
- playerX += playerStep;
- else if (keyPressed && key == 'w')
- playerY -= playerStep;
- else if (keyPressed && key == 's')
- playerY += playerStep;
- image (player, playerX, playerY, playerSize, playerSize);
- }
- void draw () {
- background (255);
- player ();
- image (donut, donutX, donutY, donutSize, donutSize);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement