Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stage {
- backdrop Sea("gallery:Nature/Sea")
- let game = true;
- let col = "Red";
- let velocity = 2;
- let gameSpeed = 8;
- let score = 0;
- let canJump = false;
- actor Ball {
- costume Green("gallery:Objects/Ball Green")
- when stage.started {
- this.setPosition(-170, 0);
- this.size = 50;
- this.show();
- this.physics.collisionShape = "circle";
- showVariable(ref score);
- game = true;
- while(game) {
- if(!this.touchingActorOrClone(Slider)) {
- this.y += velocity;
- velocity -= 0.1;
- this.wait(0.0001);
- }
- else {
- if(isKeyPressed("up arrow")) {
- if(canJump){
- score += 1;
- canJump = false;
- }
- this.y += 0.4;
- velocity = 3;
- }
- }
- }
- }
- when stage.started{
- while(game){
- this.wait(5);
- gameSpeed -= 0.5;
- }
- }
- when stage.started{
- while(game){
- if(canJump == false){
- this.wait(0.5);
- canJump = true;
- }
- if(this.y < -100){
- game = false;
- stage.broadcast("end");
- this.hide();
- }
- }
- }
- }
- actor Slider {
- default costume Red("gallery:Objects/Slider Red")
- costume Blue("gallery:Objects/Slider Blue")
- when stage.started {
- this.setPosition(-140, -50);
- this.size = 100;
- this.hide();
- for(let i = 1; i <= 10; i++) {
- createClone(this);
- this.x += 100;
- }
- while(game) {
- if(score < 21){
- createClone(this);
- this.wait(1);
- }else{
- createClone(this);
- this.wait(0.5);
- }
- }
- }
- when cloned {
- this.setCostume(Math.randomBetween(1, 2));
- this.y += Math.randomBetween(-2, 2) * 20;
- if(col == "Red") {
- if(this.costumeName == "Red") {
- this.opacity = 100;
- }
- if(this.costumeName == "Blue") {
- this.opacity = 30;
- }
- }
- if(col == "Blue") {
- if(this.costumeName == "Red") {
- this.opacity = 30;
- }
- if(this.costumeName == "Blue") {
- this.opacity = 100;
- }
- }
- this.show();
- this.glideSecondsTo(gameSpeed,this.x-1100,this.y);
- this.deleteClone(this);
- }
- when stage.keyPressed("left arrow") {
- if(this.cloneId == 0) {
- col = "Red";
- stage.broadcastAndWait("changecolor");
- }
- }
- when stage.keyPressed("right arrow") {
- if(this.cloneId == 0) {
- col = "Blue";
- stage.broadcastAndWait("changecolor");
- }
- }
- when stage.signalReceived("changecolor") {
- if(this.cloneId != 0) {
- if(col == "Red") {
- if(this.costumeName == "Red") {
- this.opacity = 100;
- }
- if(this.costumeName == "Blue") {
- this.opacity = 30;
- }
- }
- if(col == "Blue") {
- if(this.costumeName == "Red") {
- this.opacity = 30;
- }
- if(this.costumeName == "Blue") {
- this.opacity = 100;
- }
- }
- }
- }
- when cloned {
- while(game) {
- if(this.touching(Ball)) {
- if(this.opacity != 100) {
- this.wait(0.1);
- this.deleteClone(this);
- }
- }
- }
- }
- when stage.signalReceived("end"){
- deleteClone(this);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement