NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

int posX = 0, posY = 0; // Initializing values for (x, y) positions of the player
int x1, y1, x2, y2; // initializing the (x, y) values of the obstacles
boolean GO = false; // initializes the GO boolean

void setup(){
size(700, 700);
rectVals(); // sets the values for the obstacles
}
void draw(){
if (GO == false){ // exectures the game while GO is false
background(10);
Bcheck();
drawPlayer();
obstacles(x1, y1);
obstacles(x2, y2);
}

else { // executes the gameover() functions when GO is true
gameover();
}
}

void obstacles(int obstacleX, int obstacleY){ // function do draw the obstacle
fill(200);
rect(obstacleX, obstacleY, 70, 280);
if (posX >= obstacleX && posX < obstacleX + 70 && posY >= obstacleY && posY < obstacleY + 280 ){ // collision detection
GO = true;
}
}

void drawPlayer(){ // function to draw the player
stroke(255); // Player trail
line(35 + posX, 0, posX + 35, 35 + posY);

stroke(0); // body of the UFO
fill(#225D7B);
ellipse(35 + posX, 40 + posY, 60, 30);
fill(#2E97A7);
ellipse(35 + posX, 35 + posY, 70, 30);

fill(#AAE8EC); // glass part of the UFO
arc(35 + posX, 30 + posY, 40, 40, radians(180), radians(360), OPEN);
arc(35 + posX, 30 + posY, 40, 15, radians(0), radians(180), OPEN);

for(int c = 25; c < 160; c += 25){ // draws the red lights along the UFO
fill(#D02A28);
float anglerad = 2*PI*c/360;
float x = cos(anglerad)*30;
float y = sin(anglerad)*15;
circle(35 + x + posX, 28 + y + posY, 5);
}
}

void rectVals(){ // the functions rectVals() make sure that
x1 = (int)random(1, 9)*70;
x2 = (int)random(1, 9)*70;
y1 = (int)random(2, 6)*70;
y2 = (int)random(2, 6)*70;

while(x1 - x2 <= 70){
x1 = (int)random(1, 9)*70;
x2 = (int)random(1, 9)*70;
}

}
void Bcheck(){
if (posX < 0){ // checks leftmost boundary
posX = 630;
}
if (posX > width - 35){ // check rightmost boundary
posX = 0;
}
if (posY < 0){ // check upper boundary
posY = 630;
}
if (posY > height - 35){ // check lower boundary
posY = 0;
}
}

void gameover(){
background(255, 0, 0);
textSize(100);
fill(0);
text("Game Over", 120, 350);
}

void keyPressed(){
if (key == CODED){
if (keyCode == UP){
posY = posY - 70; // moves character UP
}
if(keyCode == DOWN){
posY = posY + 70; // moves character DOWN
}
if(keyCode == LEFT){
posX = posX - 70; // moves character LEFT
}
if(keyCode == RIGHT){
posX = posX + 70; // moves character RIGHT
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.