Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- // programName: BenghaziGame-kirupa.js here: http://pastebin.com/edit/Qc04CEGt
- // .html here: pastebin.com/BfBE7NUW Quick.js here: http://pastebin.com/Gzqef5fu
- /* Quick (top dog)
- Point (inherits from Quick)
- Rect (inherits from Point)
- Sprite (inherits from Rect)
- GameObject (inherits from Sprite)
- Still: Where does Pointer inherit from ? ck ~paddle-main-NOW.js for score headings
- */
- "use strict";
- // http://www.w3schools.com/js/tryit.asp?filename=tryjs_object_function
- var red = 153;
- var green = 45;
- var blue = 45;
- var truth01Trips = 0; var truth01SVspeed ; var lies01Hits = 0;
- // max trips 6 SaVe speeds
- var truth02Trips = 0; var truth02SVspeed ; var lies02Hits = 0; // max trips 4
- var truth03Trips = 0; var truth03SVspeed ; var lies03Hits = 0; // max trips 7
- var truth04Trips = 0; var truth04SVspeed ; var lies04Hits = 0; // max trips 5
- var lies01STspeed, lies02STspeed, lies03STspeed, lies04STspeed ; // STart speeds
- var lies01SVspeed, lies02SVspeed, lies03SVspeed, lies04SVspeed ; // save Speeds
- var allPaused = false;
- var compound, manufacturer, thrower;
- var truth01, truth02, truth03, truth04;
- var lies01, lies02, lies03, lies04;
- var totalScore = 0; var oopsScore = 0; var goodHits = 0; var totalShots = 0;
- var buttonsCenter = 0;
- var Cursor, cursorPoint, cursorPos;
- var getXx , getYy, countLogs =1;
- // var mousePos = [20,570];
- var mousePos1stTimeIn = 1;
- // imports
- var CommandEnum = com.dgsprb.quick.CommandEnum;
- var Quick = com.dgsprb.quick.Quick;
- var GameObject = com.dgsprb.quick.GameObject;
- var Rect = com.dgsprb.quick.Rect;
- var ImageFactory = com.dgsprb.quick.ImageFactory;
- var Scene = com.dgsprb.quick.Scene;
- var Text = com.dgsprb.quick.Text;
- var Point = com.dgsprb.quick.Point;
- // static
- function main() {
- Quick.setAutoScale(false);
- Quick.setKeepAspect(true);
- Quick.setName("Lies&Cowpies");
- Quick.init(function () { return new FirstScene() });
- }
- var Background = (function () {
- function Background() {
- GameObject.call(this);
- this.setColor("rgb(" + red + "," + green + "," + blue + ")");
- this.setWidth(Quick.getWidth());
- this.setHeight(Quick.getHeight());
- };
- Background.prototype = Object.create(GameObject.prototype);
- return Background;
- })();
- var PlayBtn = (function () { // PlayBtn class namespace
- function PlayBtn() { // PlayBtn class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("playBtn"); // setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of PlayBtn
- // getPointer is a static method of Quick
- this.setBoundary(new Rect(Quick.getCenterX() +10, 570, 100, 30)); // a method of Sprite, to set the boundaries of PlayBtn
- this.setSolid();
- this.setEssential(); // a method of GameObject, sets the PlayBtn object as essential to its Scene, that if this object expires, the scene will expire too.
- this.setBottom(600); this.setLeft(Quick.getCenterX() +10); this.setTop(572); // this.setLeft(320);
- buttonsCenter = (Quick.getCenterX() +10);
- // alert('buttonsCenter = ' + buttonsCenter);
- }
- PlayBtn.prototype = Object.create(GameObject.prototype);
- return PlayBtn; // finally publishes the class to the outer scope
- })();
- var RestartBtn = (function () { // RestartBtn class namespace
- function RestartBtn() { // RestartBtn class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("restartBtn"); // setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of RestartBtn
- this.setBoundary(new Rect(buttonsCenter -250, 570, 100, 30)); // a method of Sprite, to set this boundaries
- this.setSolid();
- this.setEssential();
- this.setBottom(600); this.setLeft(buttonsCenter -250) ; this.setTop(572);
- }
- RestartBtn.prototype = Object.create(GameObject.prototype);
- return RestartBtn; // finally publishes the class to the outer scope
- })();
- var PauseBtn = (function () { // PauseBtn class namespace
- function PauseBtn() { // PauseBtn class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("pauseBtn"); // setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of PauseBtn
- this.setBoundary(new Rect(buttonsCenter -125, 570, 100, 30)); // a method of Sprite, to set the boundaries of PauseBtn
- this.setSolid();
- this.setEssential(); // a method of GameObject, sets the PauseBtn object as essential to its Scene, that if this object expires, the scene will expire too.
- this.setBottom(600); this.setLeft(buttonsCenter -125); this.setTop(572);
- }
- PauseBtn.prototype = Object.create(GameObject.prototype);
- return PauseBtn; // finally publishes the class to the outer scope
- })();
- var QuitBtn = (function () { // QuitBtn class namespace
- function QuitBtn() { // QuitBtn class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("quitBtn"); // setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of QuitBtn
- // getPointer is a static method of Quick
- this.setBoundary(new Rect(buttonsCenter +125, 570, 100, 30)); // a method of Sprite, to set the boundaries of QuitBtn
- this.setSolid();
- this.setEssential(); // a method of GameObject, sets the QuitBtn object as essential to its Scene, that if this object expires, the scene will expire too.
- this.setBottom(600); this.setLeft(buttonsCenter + 125); this.setTop(572);
- }
- QuitBtn.prototype = Object.create(GameObject.prototype);
- return QuitBtn; // finally publishes the class to the outer scope
- })();
- var Compound = (function () { // Compound class namespace
- function Compound() { // Compound class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("bgCompound"); // setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of Compound
- // getPointer is a static method of Quick
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight())); // a method of Sprite, to set the boundaries of Compound
- this.setEssential(); // a method of GameObject, sets the Compound object as essential to its Scene, that if this object expires, the scene will expire too.
- this.setBottom(Quick.getHeight() - this.getHeight());
- this.setLeft(0); this.setTop(378);
- }
- Compound.prototype = Object.create(GameObject.prototype);
- return Compound; // finally publishes the class to the outer scope
- })();
- var Manufacturer = (function () { // Manufacturer class namespace
- function Manufacturer() { // Manufacturer class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("manufacturer"); //setImageId, a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of Manufacturer
- // getPointer is a static method of Quick
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight())); // a method of Sprite, to set the boundaries of Manufacturer
- this.setEssential(); // a method of GameObject, sets the Manufacturer object as essential to its Scene, that if this object expires, the scene will expire too.
- this.setBottom(Quick.getHeight() - this.getHeight());
- this.setLeft(618); this.setTop(468);
- }
- Manufacturer.prototype = Object.create(GameObject.prototype); // this says the Ball class
- return Manufacturer; // finally publishes the class to the outer scope
- })();
- //
- var Ball = (function () { // Ball class namespace
- function Ball() { // Ball class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("cowpieSprite"); // setImageId,a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of Ball
- // getPointer is a static method of Quick, whose public members are accessible without creating an instance of that class.
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight())); // a method of Sprite, to set the boundaries of Ball
- this.setSolid(); // a method of GameObject , so Ball can collide with other solid objects - correct!
- this.setBottom(Quick.getHeight() - this.getHeight());
- this.setTop(500);
- // this.controller = Quick.getController();
- };
- Ball.prototype = Object.create(GameObject.prototype); // this says the Ball class inherits from GameObject
- // override - this comment means the following method overrides (rewrites) the method with the same name defined in the super class (in this case, GameObject)
- Ball.prototype.onCollision = function (gameObject) { // still no instance of Ball here, just class method definition - no instance of this class is created until "new Ball()" is issued
- this.expire() ; // remove ball from screne to prevent multi hits per initial colllision
- var collision = this.getCollision(gameObject); // get direction at collision
- //
- if (gameObject.hasTag("truth01")) { // returns true if object contains given tag
- oopsScore ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2));
- truth01.setWidth(32); truth01.setHeight(32);
- };
- if (gameObject.hasTag("lies01")) { // returns true if object contains given tag
- lies01.setLeft(0); lies01.setVisible(false); lies01.setSpeedX(0);
- truth01.setVisible(true); truth01.setSpeedX(4);
- goodHits ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2)); // each goodHit = 3 points , each
- lies01Hits ++;
- if (lies01Hits % 3 === 0) {
- Quick.play('obamaVideo'); // calls a static method from Quick class
- }
- else { Quick.play("cowMoo"); // calls a static method from Quick class
- };
- };
- //
- if (gameObject.hasTag("truth02")) { // returns true if object contains given tag
- oopsScore ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2));
- truth02.setWidth(32); truth02.setHeight(32);
- Quick.play("oops"); // calls a static method from Quick class
- };
- if (gameObject.hasTag("lies02")) { // returns true if object contains given tag
- lies02.setLeft(0); lies02.setVisible(false); lies02.setSpeedX(0);
- truth02.setVisible(true); truth02.setSpeedX(4);
- goodHits ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2)); // each goodHit = 3 points , each
- lies02Hits ++;
- if (lies02Hits % 3 === 0) {
- Quick.play('Hillary-WhatDiff'); // calls a static method from Quick class
- }
- else { Quick.play("cowMoo");
- };
- };
- //
- if (gameObject.hasTag("truth03")) { // returns true if object contains given tag
- oopsScore ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2));
- truth03.setWidth(32); truth03.setHeight(32);
- Quick.play("oops"); // calls a static method from Quick class
- };
- if (gameObject.hasTag("lies03")) { // returns true if object contains given tag
- lies03.setLeft(0); lies03.setVisible(false); lies03.setSpeedX(0);
- truth03.setVisible(true); truth03.setSpeedX(4);
- goodHits ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2)); // each goodHit = 3 points , each
- lies03Hits ++;
- if (lies03Hits % 3 === 0) {
- Quick.play('eHolderVideo'); // calls a static method from Quick class
- }
- else { Quick.play("cowMoo");
- };
- };
- //
- if (gameObject.hasTag("truth04")) { // returns true if object contains given tag
- oopsScore ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2));
- truth04.setWidth(32); truth04.setHeight(32);
- Quick.play("oops"); // calls a static method from Quick class
- };
- if (gameObject.hasTag("lies04")) { // returns true if object contains given tag
- lies04.setLeft(0); lies04.setVisible(false); lies04.setSpeedX(0);
- truth04.setVisible(true); truth04.setSpeedX(4);
- goodHits ++ ; totalScore = ((goodHits * 4) - (oopsScore * 2)); // each goodHit = 3 points , each
- lies04Hits ++;
- if (lies04Hits % 3 === 0) {
- Quick.play('sRiceVideo'); // calls a static method from Quick class
- }
- else { Quick.play("cowMoo");
- };
- };
- //
- updateScores();
- };
- return Ball; // finally publishes the class to the outer scope
- })();
- function updateScores () {
- document.getElementById('totalScore').innerHTML = totalScore;
- document.getElementById('oopsScore').innerHTML = oopsScore;
- document.getElementById('goodHits').innerHTML = goodHits;
- document.getElementById('totalShots').innerHTML = totalShots;
- if(goodHits === 100) { Quick.play('cheering'); };
- }
- //
- //
- window.addEventListener('resize', resizeCanvas, false);
- function resizeCanvas () {
- var myCanvas = document.getElementById('canvas');
- // canvasDiv = canvasDiv.align = 'center';
- // myCanvas.width = document.documentElement.innerWidth; // .inner* = Black Screen
- myCanvas.width = document.documentElement.clientWidth; // .client* = bad canvas align
- myCanvas.height = document.documentElement.clientHeight; // .client* = bad canvas align
- // myCanvas.height = document.documentElement.innerHeight; // .inner* = Black Screen
- Quick.setAutoScale(false);
- Quick.setKeepAspect(true);
- } //
- /*
- window.addEventListener("resize", function(){
- location.reload(); // 867x661 1027x773 if (i % 3 == 0) {};
- Quick.setAutoScale(false);
- Quick.setKeepAspect(true);
- // truth02.setWidth(64); truth02.setHeight(64);
- var myCanvas = document.getElementById(“canvas”);
- myCanvas.width = 800;
- myCanvas.height = 600;
- } );
- */
- var Truth = (function () {
- function Truth() {
- GameObject.call(this);
- this.setImageId("");
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight()));
- // this.setEssential();
- this.setSolid();
- this.setLeft(0);
- this.setTop(120);
- this.setSpeedX(4);
- };
- Truth.prototype = Object.create(GameObject.prototype);
- Truth.prototype.offBoundary = function (gameObject) {
- if (this.hasTag("truth02")) {
- truth02Trips += 1; // increment by 1
- if(truth02Trips > 2) { truth02Trips = 0;
- truth02.setLeft(0); truth02.setVisible(false); truth02.setSpeedX(0);
- };
- // Quick.play("oops"); // calls a static method from Quick class
- if(truth02.getVisible() ) { this.bounceX(); // for the horizontal axis
- this.setImage(ImageFactory.mirror(this.getImage())); // flip image horiz
- };
- if(!truth02.getVisible() ) { // if not visible
- lies02.setLeft(0); lies02.setVisible(true); lies02.setSpeedX(4); //
- };
- };
- //
- if (this.hasTag("truth01")) {
- truth01Trips += 1; // increment by 1
- if(truth01Trips > 2) { truth01Trips = 0;
- truth01.setLeft(0); truth01.setVisible(false); truth01.setSpeedX(0);
- };
- // Quick.play("obamaVideo.ogg"); // calls a static method from Quick class
- if(truth01.getVisible() ) { this.bounceX(); // for the horizontal axis
- this.setImage(ImageFactory.mirror(this.getImage())); // flip image horiz
- };
- if(!truth01.getVisible() ) {
- lies01.setLeft(0); lies01.setVisible(true); lies01.setSpeedX(4); //
- };
- };
- //
- if (this.hasTag("truth03")) {
- truth03Trips += 1; // increment by 1
- if(truth03Trips > 2) { truth03Trips = 0;
- truth03.setLeft(0); truth03.setVisible(false); truth03.setSpeedX(0);
- };
- // Quick.play("oops"); // calls a static method from Quick class
- if(truth03.getVisible() ) { this.bounceX(); // for the horizontal axis
- this.setImage(ImageFactory.mirror(this.getImage())); // flip image horiz
- };
- if(!truth03.getVisible() ) {
- lies03.setLeft(0); lies03.setVisible(true); lies03.setSpeedX(4); //
- };
- };
- //
- if (this.hasTag("truth04")) {
- truth04Trips += 1; // increment by 1
- if(truth04Trips > 2) { truth04Trips = 0;
- truth04.setLeft(0); truth04.setVisible(false); truth04.setSpeedX(0);
- };
- // Quick.play("oops"); // calls a static method from Quick class
- if(truth04.getVisible() ) { this.bounceX(); // for the horizontal axis
- this.setImage(ImageFactory.mirror(this.getImage())); // flip image horiz
- };
- if(!truth04.getVisible() ) {
- lies04.setLeft(0); lies04.setVisible(true); lies04.setSpeedX(4); //
- };
- };
- //
- };
- return Truth;
- })();
- //
- var Lies = (function () {
- function Lies() {
- GameObject.call(this);
- this.setImageId("");
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight()));
- // this.setEssential();
- this.setSolid();
- this.setLeft(0);
- this.setTop(120);
- this.setSpeedX(5);
- };
- Lies.prototype = Object.create(GameObject.prototype);
- Lies.prototype.offBoundary = function (gameObject) {
- this.bounceX(); // for the horizontal axis
- this.setImage(ImageFactory.mirror(this.getImage()));
- // alert("Lies.prototype.offBoundary");
- };
- return Lies;
- })();
- //
- var FirstScene = (function () {
- function FirstScene() {
- Scene.call(this);
- this.add(new Background());
- var compound = new Compound();
- this.add(compound);
- var playBtn = new PlayBtn();
- this.add(playBtn);
- playBtn.addTag("playBtn");
- var restartBtn = new RestartBtn();
- this.add(restartBtn);
- restartBtn.addTag("restartBtn");
- var pauseBtn = new PauseBtn();
- this.add(pauseBtn);
- pauseBtn.addTag("pauseBtn");
- var quitBtn = new QuitBtn();
- this.add(quitBtn);
- quitBtn.addTag("quitBtn");
- manufacturer = new Manufacturer();
- this.add(manufacturer);
- var ball = new Ball();
- truth01 = new Truth();
- this.add(truth01);
- truth01.addTag("truth01");
- truth01.setImageId("truth01Sprite");
- truth01.setLeft(0);
- truth01.setTop(0);
- truth01.setSpeedX(4);
- lies01 = new Lies();
- this.add(lies01);
- lies01.addTag("lies01");
- lies01.setImageId("lies01Sprite");
- lies01.setVisible(false);
- lies01.setLeft(0) // (-64);
- lies01.setTop(0);
- lies01.setSpeedX(0);
- truth02 = new Truth();
- this.add(truth02);
- truth02.addTag("truth02");
- truth02.setImageId("truth02Sprite");
- truth02.setLeft(0);
- truth02.setTop(70);
- truth02.setVisible(false);
- truth02.setSpeedX(0);
- lies02 = new Lies();
- this.add(lies02);
- lies02.addTag("lies02");
- lies02.setImageId("lies02Sprite");
- lies02.setLeft(0) // (-64);
- lies02.setTop(70);
- lies02.setSpeedX(6);
- truth03 = new Truth();
- this.add(truth03);
- truth03.addTag("truth03");
- truth03.setImageId("truth03Sprite");
- truth03.setLeft(0);
- truth03.setTop(140);
- truth03.setSpeedX(3);
- lies03 = new Lies();
- this.add(lies03);
- lies03.addTag("lies03");
- lies03.setImageId("lies03Sprite");
- lies03.setVisible(false);
- lies03.setLeft(0) // (-64);
- lies03.setTop(140);
- lies03.setSpeedX(0);
- truth04 = new Truth();
- this.add(truth04);
- truth04.addTag("truth04");
- truth04.setImageId("truth04Sprite");
- truth04.setLeft(-64);
- truth04.setTop(210);
- truth04.setSpeedX(5);
- lies04 = new Lies();
- this.add(lies04);
- lies04.addTag("lies04");
- lies04.setImageId("lies04Sprite");
- lies04.setVisible(false);
- lies04.setLeft(-64) // (-64);
- lies04.setTop(210);
- lies04.setSpeedX(0);
- thrower = new Thrower();
- this.add(thrower);
- var cursorPoint = new Cursor();
- this.add(cursorPoint);
- var spark = new Spark();
- this.add(spark);
- alert( '<--- Arrow = move Left .\n' + '---> Arrow = move Right .\n' + ' Up Arrow = Throw Cowpie \n ' + '\n Best Screen size: Width = >840 , Height = > 640 .\n' +
- '\n Cheering after every 100 goodHits . \n' +
- '\n Click anywhere on screen to ACTIVATE BUTTONS .\n');
- Quick.play("battleFire"); // calls a static method from Quick class
- };
- FirstScene.prototype = Object.create(Scene.prototype);
- // override
- FirstScene.prototype.getNext = function () {
- return new FirstScene();
- };
- return FirstScene;
- })();
- //
- var Cursor = (function () {
- function Cursor() {
- GameObject.call(this);
- this.addTag("pointerSprite");
- this.controller = Quick.getController();
- this.setBoundary(new Rect(0, 600, Quick.getWidth(), 30)); // a method of Sprite,set Boundary
- this.pointer = Quick.getPointer();
- this.setImageId("pointerSprite");
- this.setSolid();
- this.setEssential();
- this.setBottom(600); this.setLeft(50); this.setTop(572);
- };
- Cursor.prototype = Object.create(GameObject.prototype);
- Cursor.prototype.fire = function () {
- var spark = new Spark(); // create a brand new spark to be thrown
- var scene = this.getScene(); // ask for the scene the avatar is
- scene.add(spark); // add the spark to the same scene I am
- if (spark) {spark.setX(this.getX()) };
- spark.setSpeedY(10);
- };
- Cursor.prototype.update = function () {
- if (this.pointer.getPush()) { // getpush is a method of Pointer as in Mouse pointer
- this.fire(); // call the Cursor.prototype.fire method we defined above
- var position = this.pointer.getPosition();
- };
- var mousePos = this.pointer.getPosition();
- this.setPosition(mousePos);
- }
- Cursor.prototype.offBoundary = function (gameObject) {
- // alert('Cursor.prototype.offBoundary');
- // this.setCenterY(587);
- };
- // this.setCenterY(587);
- return Cursor;
- })();
- var Spark = (function () { // Spark class namespace
- function Spark() { // Spark class constructor method
- GameObject.call(this); // call the constructor from the superclass
- this.setImageId("sparkSprite"); // setImageId,a method inherited from Sprite
- // this.pointer = Quick.getPointer(); // pointer is a member property of Spark
- this.setBoundary(new Rect(0, 600, Quick.getWidth(), 30)); // a method of Sprite,set
- this.setSolid(); // a method of GameObject , so Spark can collide with other solid objects
- this.setBottom(600); this.setLeft(50); this.setTop(578);
- this.controller = Quick.getController();
- };
- Spark.prototype = Object.create(GameObject.prototype);
- Spark.prototype.onCollision = function (gameObject) {
- var collision = this.getCollision(gameObject); // get direction at collision
- if (gameObject.hasTag("restartBtn")) { // returns true if object contains given tag
- Quick.play("closeDoor"); // calls a static method from Quick class
- totalScore = 0; oopsScore = 0; goodHits = 0; totalShots = 0;
- updateScores();
- }
- if (gameObject.hasTag("pauseBtn")) { // returns true if object contains given tag
- Quick.play("pling"); // calls a static method from Quick class
- if(!allPaused) {
- truth01SVspeed = truth01.getSpeedX(); truth01.setSpeedX(0); // this.setSpeedX(5);
- lies01SVspeed = lies01.getSpeedX(); lies01.setSpeedX(0); // this.setSpeedX(5);
- truth02SVspeed = truth02.getSpeedX(); truth02.setSpeedX(0); // this.setSpeedX(5);
- lies02SVspeed = lies02.getSpeedX(); lies02.setSpeedX(0); // this.setSpeedX(5);
- truth03SVspeed = truth03.getSpeedX(); truth03.setSpeedX(0); // this.setSpeedX(5);
- lies03SVspeed = lies03.getSpeedX(); lies03.setSpeedX(0); // this.setSpeedX(5);
- truth04SVspeed = truth04.getSpeedX(); truth04.setSpeedX(0); // this.setSpeedX(5);
- lies04SVspeed = lies04.getSpeedX(); lies04.setSpeedX(0); // this.setSpeedX(5);
- allPaused = true;
- }
- else { alert('You are already paused , try Play .');
- }
- }; // gameObject.hasTag
- //
- if (gameObject.hasTag("playBtn")) { // returns true if object contains given tag
- Quick.play("pling"); // calls a static method from Quick class
- if(allPaused) {
- allPaused = false;
- truth01.setSpeedX(truth01SVspeed);
- lies01.setSpeedX(lies01SVspeed);
- truth02.setSpeedX(truth02SVspeed); truth02.setWidth(64); truth02.setHeight(64);
- lies02.setSpeedX(lies02SVspeed);
- truth03.setSpeedX(truth03SVspeed);
- lies03.setSpeedX(lies03SVspeed);
- truth04.setSpeedX(truth04SVspeed);
- lies04.setSpeedX(lies04SVspeed);
- }
- };
- if (gameObject.hasTag("quitBtn")) { // returns true if object contains given tag
- Quick.play("byebye"); // calls a static method from Quick class
- window.location = 'https://github.com/dgsprb/quick/wiki';
- };
- };
- return Spark; // finally publishes the class to the outer scope
- })();
- //
- var Thrower = (function () {
- function Thrower() {
- GameObject.call(this);
- this.addTag("thrower");
- this.controller = Quick.getController();
- this.setBoundary(new Rect(0, 0, Quick.getWidth(), Quick.getHeight()));
- this.pointer = Quick.getPointer();
- this.setImageId("throwerSprite");
- this.setEssential();
- this.setCenterX(Quick.getWidth() / 2);
- this.setBottom(Quick.getHeight() - this.getHeight());
- this.setTop(506);
- };
- Thrower.prototype = Object.create(GameObject.prototype);
- Thrower.prototype.fire = function () {
- var ball = new Ball(); // create a brand new ball to be thrown
- var scene = this.getScene(); // ask for the scene the avatar is
- scene.add(ball); // add the ball to the same scene I am
- if (ball) {ball.setX(this.getX()) }; // within your Thrower update method
- // totalShots ++ ;
- updateScores();
- // if(ball ) { this.ball.setCenterX(this.getCenterX()) } ;
- ball.setSpeedY(-9);
- };
- Thrower.prototype.update = function () {
- if (this.controller.keyDown(CommandEnum.LEFT) && this.getLeft() > 0) {
- this.moveX(-8);
- }
- if (this.controller.keyDown(CommandEnum.RIGHT) && this.getRight() < Quick.getWidth()) {
- this.moveX(8);
- }
- if (this.controller.keyPush(CommandEnum.UP) || this.controller.keyPush(CommandEnum.A))
- { totalShots += 1;
- this.fire(); // call the method we defined above
- }
- }
- Thrower.prototype.offBoundary = function (gameObject) {
- this.setCenterX(Quick.getWidth() / 2);
- };
- return Thrower;
- })();
- main();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement