[EN] Ada Lovelace Day 2014 - Tampon run

75
LFU - 12. October 2014 - Ljubljana - KCQ

description

Ada Lovelace Day 2014 Workshop https://www.facebook.com/princessdesignnet

Transcript of [EN] Ada Lovelace Day 2014 - Tampon run

Page 1: [EN] Ada Lovelace Day 2014  - Tampon run

LFU - 12. October 2014 - Ljubljana - KCQ

Page 2: [EN] Ada Lovelace Day 2014  - Tampon run

AdaLovelaceL. F. Menabrea: Sketch of The Analytical Engine Invented by Charles Babbage Note G

Page 3: [EN] Ada Lovelace Day 2014  - Tampon run
Page 4: [EN] Ada Lovelace Day 2014  - Tampon run

Have the courage to try. You can make amazing things happen.Megan Smith, U.S. CTO, former VP of Google[x]

Photo: Taylor Hill/FilmMagic for Google

Page 5: [EN] Ada Lovelace Day 2014  - Tampon run
Page 6: [EN] Ada Lovelace Day 2014  - Tampon run
Page 7: [EN] Ada Lovelace Day 2014  - Tampon run
Page 8: [EN] Ada Lovelace Day 2014  - Tampon run

Source CodeOriginal: https://github.com/andrea-3000/TAMPON-RUN Workshop Copy: https://github.com/princessdesign/TAMPON-RUN

Page 9: [EN] Ada Lovelace Day 2014  - Tampon run

Building Blocks● HTML ● CSS● JavaScript

○ Processing.js http://processingjs.org/○ Buzz a Javascript HTML5 Audio library http://buzz.jaysalvat.com/

● Images, music

Page 10: [EN] Ada Lovelace Day 2014  - Tampon run

Avatars / Images

Page 11: [EN] Ada Lovelace Day 2014  - Tampon run

Navigation with Keys● RIGHT: 39 // forward● LEFT: 37 // back● M: 77 // mute● SHIFT: 16 // begin● SPACE: 32 // throw tampon● UP: 38 // jump● P: 80 // pause● S: 83 // restart

Page 12: [EN] Ada Lovelace Day 2014  - Tampon run

Music● beethovenSound● jumpSound● tamponSound● gameOverSound● ouchSound● shootSound

Page 13: [EN] Ada Lovelace Day 2014  - Tampon run

Let’s make our own game...

Page 14: [EN] Ada Lovelace Day 2014  - Tampon run

Play the game for the next 5 minutes and make a list of things you would like to change.

Page 15: [EN] Ada Lovelace Day 2014  - Tampon run

● ____________● ____________● ____________● ____________● ____________

● ____________● ____________● ____________● ____________● ____________

TODO

Page 16: [EN] Ada Lovelace Day 2014  - Tampon run

DOABLE TODAY● ____________● ____________● ____________● ____________● ____________

Page 17: [EN] Ada Lovelace Day 2014  - Tampon run

● Skip intro and go directly to the game● Navigation keys● Initial number of tampons● Number of tampons in the pack● Color of tampons● Avatar of the enemy● Animations● Background color● Ground color● Cloud color

What can we ‘easily’ change?

● Image of the lamppost● Change lamppost into another object● The height of the jump● Larger canvas with the game● Change Intro Images (Translate)● Change sounds● ...

Page 18: [EN] Ada Lovelace Day 2014  - Tampon run

Let’s do it...

Page 19: [EN] Ada Lovelace Day 2014  - Tampon run
Page 20: [EN] Ada Lovelace Day 2014  - Tampon run
Page 21: [EN] Ada Lovelace Day 2014  - Tampon run

index.html

Page 22: [EN] Ada Lovelace Day 2014  - Tampon run

<html> <head> <title>Tampon Run!</title>

<style type="text/css"> /* CSS CODE for STYLE */ </style>

<script src="lib/processing-1.4.1.min.js"></script> <script src="lib/buzz.min.js" type="text/javascript"></script>

<script type="text/processing" data-processing-target="creators">// JAVASCRIPT CODE (creators canvas)

</script>

<script type="text/processing" data-processing-target="mycanvas">/* JAVASCRIPT CODE FOR THE GAME (mycanvas canvas) */

</script> </head>

<body> <canvas id="creators"></canvas> <canvas id="mycanvas"></canvas> </body></html>

Page 23: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

JavaScript Basics

Page 24: [EN] Ada Lovelace Day 2014  - Tampon run

brackets.io

Page 25: [EN] Ada Lovelace Day 2014  - Tampon run
Page 26: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Comments// Hi, my name is comment

/*I am comment too. I can take more space.*/

Page 27: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

test.html

<html><head>

<script>console.log("JavaScript");

</script></head><body></body>

</html>

Page 28: [EN] Ada Lovelace Day 2014  - Tampon run

Google Chrome Console

Page 29: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Numbers141+15-232*3829/35%4

Page 30: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Strings"Ada" "Lovelace""Ada".length "Lovelace".length

Page 31: [EN] Ada Lovelace Day 2014  - Tampon run
Page 32: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Booleantruefalse1<2

Page 33: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Variablesvar score = 0; // numberscore;console.log(score);

var muted = false; // boolean

var feedback = "I feel awesome";

Page 34: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Arraysvar lampList = [];

var tampons = ["red", "green", "blue"];

var first = tampons[0];

console.log(first);

console.log(tampons[0]);

Page 35: [EN] Ada Lovelace Day 2014  - Tampon run
Page 36: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Functionsconfirm("I feel awesome!");

prompt("What is your name?");

console.log("What is your name?");

Page 37: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Functionsvar sayHello = function(name) {

console.log("Hello" + " " + name);

};

sayHello("Maja");

Page 38: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

Functions / Methodsvoid pauseSound(soundToPlay) {

soundToPlay.pause()

}

Page 39: [EN] Ada Lovelace Day 2014  - Tampon run
Page 40: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

if sentencevar x = 1;if ( x == 1) {

console.log("x equals 1");}

Page 41: [EN] Ada Lovelace Day 2014  - Tampon run
Page 42: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

if sentencevar x = 4;if ( x !== 1) {console.log("x doesn’t equal 1");}

Page 43: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

if else var key = "left";

if (key == "up" ){console.log("Key is up.");

} else {console.log("Some key.");

}

Page 44: [EN] Ada Lovelace Day 2014  - Tampon run
Page 45: [EN] Ada Lovelace Day 2014  - Tampon run
Page 46: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<10; count++){

console.log(count);}

if & else if & elsevar key = "left";

if (key == "right" ) {console.log("Key is right.");

} else if (key == "up" ){console.log("Key is up.");

} else {console.log("Some key.");

}

Page 47: [EN] Ada Lovelace Day 2014  - Tampon run
Page 48: [EN] Ada Lovelace Day 2014  - Tampon run

for loopfor(var count=0; count<100; count++){

console.log(count);}

Page 49: [EN] Ada Lovelace Day 2014  - Tampon run

for looptowns = ["LJ", "MB", "KR", "NM", "KP", "GO", "KR"];

for(var i=0; i<towns.length; i++){document.write(towns[i]);document.write("<br />")

}

Page 50: [EN] Ada Lovelace Day 2014  - Tampon run

Classes and objectsAnimationGameStateLamppostLampFactoryCloudCloudFactoryGunAmmo

BuildingFactoryEnemyFactoryDuaneReadeBuildingPlayerEnemyTampon

Page 51: [EN] Ada Lovelace Day 2014  - Tampon run

class Tampon { var xTamp; var yTamp; var tampSpeed; var randFR; Animation tampPic; var h; var w;

Tampon() { xTamp = 750; yTamp = 250; tampSpeed = -2; randFR = Math.floor((Math.random() * 20) + 8); tampPic = new Animation("tampz", 2, randFR); h = tampPic.getHeight(); w = tampPic.getWidth(); }

void showTamp() { tampPic.display(xTamp, yTamp); }

void moveTamp() { xTamp = xTamp + tampSpeed; }

void releaseTamp() { yTamp = yTamp + tampSpeed; } }

class DuaneReade { var tamponList;

DuaneReade() { tamponList = []; }

void animate() { var willItBlend = Math.floor((Math.random() * 500) + 1); if (willItBlend == 50) { tamponList.push(new Tampon()); }

showTamponList(); moveTamponList(); removeTampon(); reloadTampon(); }

// MORE CODE...

}

Page 52: [EN] Ada Lovelace Day 2014  - Tampon run

Methodsplay(soundToPlay)pauseSound(SoundToPlay)setup()draw()keyPressed()keyReleased()

Page 53: [EN] Ada Lovelace Day 2014  - Tampon run

Remember what you wanted to change in the game?

Page 54: [EN] Ada Lovelace Day 2014  - Tampon run

● Skip intro and go directly to the game● Navigation keys● Initial number of tampons● Number of tampons in the pack● Color of tampons● Avatar of the enemy● Animations● Background color● Ground color● Cloud color

What can we ‘easily’ change?

● Image of the lamppost● Change lamppost into another object● The height of the jump● Larger canvas with the game● Change Intro Images (Translate)● Change sounds● ...

Page 55: [EN] Ada Lovelace Day 2014  - Tampon run

Skip introHINT: If you are on the first page (0: home) press SHIFT (key 16) and go to the game page (3: game play)

if (keyCode == 16 && state.page==0){

state.page = 1; // change to 3

Why is sound not playing?

Page 56: [EN] Ada Lovelace Day 2014  - Tampon run

Change navigation keysif (keyCode == 77)if (keyCode == 39)if (keyCode == 16)if (keyCode == 83)if (keyCode == 38)

TASK: Change the code so that you will be able to play the game with one hand!

SPACE: 32 // throw tamponRIGHT: 39 // forwardLEFT: 37 // backM: 77 // muteSHIFT: 16 // beginUP: 38 // jumpP: 80 // pauseS: 83 // restart

Page 57: [EN] Ada Lovelace Day 2014  - Tampon run

Change the number of initial tamponsHINT: find where the number is defined and change it

//player variables

var tampon = 10; //50

TASK: What happens if we restart the game (S)? Fix it!

HINT: Find where the conditions are end screen (4) and key S (83).

Page 58: [EN] Ada Lovelace Day 2014  - Tampon run

Change the number of tampons in the packHINT: Find where the number is defined and change it

tampon = tampon + 5 // 50

Page 59: [EN] Ada Lovelace Day 2014  - Tampon run

Change intro imagesstatementOne = loadImage("res/statementOne0000.png");

statementTwo = loadImage("res/statementTwo0000.png");

statementThree = loadImage("res/statementThree0000.png");

statementFour = loadImage("res/statementFour0000.png");

statementFive = loadImage("res/statementFive0000.png");

instructOne = loadImage("res/learn0000.png");

pausePage = loadImage("res/pause0000.png");

Page 60: [EN] Ada Lovelace Day 2014  - Tampon run

Color of tamponsTASK: Open images in image

editor and change the color.

● ammo…png 4x

● attack…png 2x

Page 61: [EN] Ada Lovelace Day 2014  - Tampon run

New enemyenemies = new EnemyFactory("eWalk", 1);

/* change to swat and play the game */

TASK: Now try to build your own.

eWalk swat

Page 62: [EN] Ada Lovelace Day 2014  - Tampon run

AnimationsAnimation title;

title = new Animation("title", 2, 20);

Animation girlIntro;

girlIntro = new Animation("walk",2,5);

Page 63: [EN] Ada Lovelace Day 2014  - Tampon run

Background coloorvoid startGame() {background(100);

/* background(255,255,0); //yellow (red, green and blue 0-255)color yellow = color(255,252, 25);color red = color(178,18,18);color orange = color(255,83, 13);color blue = color(9, 113, 178);color pink = color(255, 182, 193);*/

Page 64: [EN] Ada Lovelace Day 2014  - Tampon run

Ground colorvoid showBuilding() {fill(0); // color name or number(s)

/* background(255,255,0); //yellow (red, green and blue 0-255)color yellow = color(255,252, 25);color red = color(178,18,18);color orange = color(255,83, 13);color blue = color(9, 113, 178);color pink = color(255, 182, 193);*/

Page 65: [EN] Ada Lovelace Day 2014  - Tampon run

Change the cloud colorvoid showCloud() {

fill(255);

fill(0); // black or // (0,0,0) (red, green and blue 0-255)

Page 66: [EN] Ada Lovelace Day 2014  - Tampon run

Change the cloud colorGray clouds (uncomment c and add c to fill())

c = Math.floor((Math.random() * 255) + 1);

}

void showCloud() {

fill(c);

Page 67: [EN] Ada Lovelace Day 2014  - Tampon run

Change the cloud colorColor clouds r = Math.floor((Math.random() * 255) + 1);

g = Math.floor((Math.random() * 255) + 1);

b = Math.floor((Math.random() * 255) + 1);

}

void showCloud() {

fill(r,g,b);

Page 68: [EN] Ada Lovelace Day 2014  - Tampon run

Image of lamppostTASK: Open the image

lamppost0000.png in Image editor

and change it.

Page 69: [EN] Ada Lovelace Day 2014  - Tampon run

Height of the jumpjumpHeight = 200;

/*

jumpHeight = 100; // higher

jumpHeight = 300; // lower

*/

Page 70: [EN] Ada Lovelace Day 2014  - Tampon run

Larger game canvasvar CANVAS_HEIGHT = 500; // 700

var CANVAS_WIDTH = 700; // 1200

Page 71: [EN] Ada Lovelace Day 2014  - Tampon run

Change soundsvar jumpSound = new buzz.sound("res/sound/jumpSound", {formats: ["ogg", "mp3"]});

var tamponSound = new buzz.sound("res/sound/tamponSound", {formats: ["ogg", "mp3"]});

var gameOverSound = new buzz.sound("res/sound/gameOverSound", {formats: ["ogg", "mp3"]});

var beethovenSound = new buzz.sound("res/sound/beethovenSound", {formats: ["ogg", "mp3"]});

var ouchSound = new buzz.sound("res/sound/ouchSound", {formats: ["ogg", "mp3"]});

var shootSound = new buzz.sound("res/sound/shootSound", {formats: ["ogg", "mp3"]});

Page 72: [EN] Ada Lovelace Day 2014  - Tampon run

You can leave behind the old regressive sexist representations andinstead create interactive experiences that portray women as capable, complex and inspirational.Anita Sarkeesian, Feminist Frequency

Page 73: [EN] Ada Lovelace Day 2014  - Tampon run

JAVASCRIPT REFERENCEhttp://learnxinyminutes.com/docs/javascript/http://www.codecademy.com/glossary/javascript https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide

TUTORIALShttp://www.codecademy.com/tracks/javascripthttps://www.khanacademy.org/computing/cs

Page 74: [EN] Ada Lovelace Day 2014  - Tampon run

PROCESSINGJS REFERENCEhttp://processingjs.org/reference/