Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Creating variables
- var myX = 0, myY = 0, platformaX=[], platformaY=[], iPl, vragplX=300, vragplY=860;
- var score=0
- platformaX[0]=200
- platformaY[0]=620
- platformaX[1]=300
- platformaY[1]=700
- platformaX[2]=430
- platformaY[2]=780
- function update() {
- myX = mouseX
- myY = myY+1
- vragplY=vragplY-3
- if(vragplY<0){
- vragplY=860
- vragplX=randomInteger(720)
- }
- platformaY[0] = platformaY[0]-3
- platformaY[1] = platformaY[1]-3
- platformaY[2] = platformaY[2]-3
- for(iPl=0;iPl<3;iPl=iPl+1){
- if(areColliding(myX, myY, 15, 15, platformaX[iPl], platformaY[iPl], 80, 10)){
- myY = myY-2
- myY=platformaY[iPl]-15
- score=score+1
- }
- }
- for(iPl=0;iPl<3;iPl=iPl+1){
- if(platformaY[iPl]<0){
- platformaX[iPl]=randomInteger(720)
- platformaY[iPl]=620
- }
- }
- if(myY>600){
- myY=99999
- score=score
- window.alert("Sry Ma Frend. Press F12 to see your score");
- console.log("Your score is", score)
- }
- if(myY<0){
- myY=99999
- score=score
- window.alert("Sry Ma Frend. Press F12 to see your score");
- console.log("Your score is", score)
- }
- if(areColliding(myX, myY, 15, 15, vragplX, vragplY, 80, 10)){
- myY=99999
- score=score
- window.alert("Sry Ma Frend. Press F12 to see your score") ;
- console.log("Your score is", score)
- }
- }
- function draw() {
- // This is how you draw a rectangle
- context.fillStyle="Black"
- context.fillRect(0, 0, 800, 600);
- context.fillStyle="blue"
- context.fillRect(myX, myY, 15, 15);
- context.fillStyle="Red"
- context.fillRect(platformaX[0], platformaY[0], 80, 10);
- context.fillRect(platformaX[1], platformaY[1], 80, 10);
- context.fillRect(platformaX[2], platformaY[2], 80, 10);
- context.fillStyle="purple"
- context.fillRect(vragplX, vragplY, 80, 10);
- };
- function keyup(key) {
- // Show the pressed keycode in the console
- console.log("Pressed", key);
- };
- function mouseup() {
- // Show coordinates of mouse on click
- console.log("Mouse clicked at", mouseX, mouseY);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement