Skip to content

Commit

Permalink
add kids
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham committed Sep 19, 2021
1 parent bb2698f commit cacceca
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
21 changes: 6 additions & 15 deletions bird.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@ function Bird() {
fill(255);
//ellipse(this.x, this.y, 2 * this.r, 2 * this.r);
imageMode(CENTER);
if (userimg) lol = userimg;
if (userimg) picture = userimg;
else if (kid == "vaibhav") picture = s[2]
else if (kid == "ahana") picture = s[4]
else if (kid == "harman") picture = s[5]
else
switch (pic) {
case 0:
lol = s1;
break;
case 1:
lol = s2;
break;
case 2:
lol = s3;
break;
case 3:
lol = toruss;
}
image(lol, this.x, this.y, 2 * this.r, 2 * this.r);
picture = s[pic_num]
image(picture, this.x, this.y, 2 * this.r, 2 * this.r);
}

this.up = function () {
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
<script language="javascript" src="libraries/p5.dom.js"></script>
<script language="javascript" src="libraries/p5.sound.js"></script>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"></script>
<script language="javascript" type="text/javascript" src="sketch.js"></script>
<script language="javascript" type="text/javascript" src="bird.js"></script>
<script language="javascript" type="text/javascript" src="pipe.js"></script>
Expand Down
File renamed without changes
Binary file added resources/pexels-photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added resources/s2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added resources/s4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/s5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file removed s2.png
Binary file not shown.
30 changes: 19 additions & 11 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ var pause = false;
var frameCunt = 0;
var speed;
var uptree, downtree;
var pic;
var number_of_pictures = 6;
var pic_num;
var s = [];
var kid;
var userimg;
var resources_dir = "resources/"
var msgcount = 2;
window.mobilecheck = function () {
var check = false;
Expand All @@ -19,18 +23,22 @@ window.mobilecheck = function () {
var mobile = mobilecheck();

function preload() {
toruss = loadImage('torus.png');
s1 = loadImage('s1.png');
s2 = loadImage('s2.png');
s3 = loadImage('s3.png');
uptree = loadImage('spooky_tree_upright.png');
downtree = loadImage('spooky_tree_inverted.png')
bg = loadImage('pexels-photo.jpg');
var i = 0
while (i < number_of_pictures) {
s.push(loadImage(resources_dir+'s'+i+'.png'))
i = i + 1
}
uptree = loadImage(resources_dir+'spooky_tree_upright.png');
downtree = loadImage(resources_dir+'spooky_tree_inverted.png')
bg = loadImage(resources_dir+'pexels-photo.jpg');

}

function setup() {
//var c = createCanvas(1300, 580);
kid = "null"
if (getURLParams().kid)
kid = getURLParams().kid.toLowerCase();
c = createCanvas(innerWidth, innerHeight);
bird = new Bird;
if (!mobile) {
Expand All @@ -40,7 +48,7 @@ function setup() {
slider = createSlider(0, 10, 4, 1);
slider.position(width - 150, 50);
}
pic = floor(random(4));
pic_num = floor(random(number_of_pictures));
pipes.push(new Pipe());
pipes.push(new Pipe());
pipes[1].x = width / 2 + 1360 / 4;
Expand Down Expand Up @@ -80,7 +88,7 @@ function draw() {
if (!pause) {
imageMode(CORNER);
background(bg);

if (!mobile) {
speed = slider.value();
} else speed = 4;
Expand All @@ -91,7 +99,7 @@ function draw() {

if (pipes[i].hits(bird)) {
//console.log("HIT");
pic = floor(random(4));
pic_num = floor(random(number_of_pictures));
}

if (pipes[i].offscreen()) {
Expand Down

0 comments on commit cacceca

Please sign in to comment.