(canvas.height - 1 - this.bitmap.length)) {
+ this.y = canvas.height - 1 - this.bitmap.length;
+ }
+ }
+ return galinha;
+ }
+
+ function inverter_vertical(bitmap) {
+
+ var resultado = new Array();
+
+ for (var linha in bitmap) {
+ var linha_corrente = bitmap[linha];
+ var nova_linha = new Array();
+ var num_itens = linha_corrente.length;
+
+ for (x = num_itens - 1; x >= 0; x = x - 1) {
+ nova_linha.push(linha_corrente[x]);
+ }
+ resultado.push(nova_linha);
+ }
+ return resultado;
+ }
+
+
+
+ function substituir(valor_original, valor_substituto, bitmap) {
+
+ var resultado = new Array();
+
+ for (var linha in bitmap) {
+
+ var nova_linha = new Array()
+ var linha_corrente = bitmap[linha]
+ for (var x = 0; x < linha_corrente.length; x = x + 1) {
+ nova_linha.push(linha_corrente[x] == valor_original ? valor_substituto : linha_corrente[x]);
+ }
+ resultado.push(nova_linha);
+ }
+ return resultado;
+ }
+
+
+ var carro_invertido = inverter_vertical(carro);
+
+
+ function criarCarro(x, y, bitmap, direcao) {
+ var result = new Object();
+ result.x = x;
+ result.y = y + 20;
+ result.bitmap = bitmap;
+ result.width = bitmap[0].length;
+ result.height = bitmap.length;
+ result.direcao = direcao;
+
+ result.move = function() {
+ this.x = this.x + direcao;
+ if (this.x < 0 && this.direcao < 0) {
+ this.x = canvas.width + 10;
+ } else if (this.x > canvas.width && this.direcao > 0) {
+ this.x = -20;
+ }
+ }
+
+ result.pegouGalinha = function(galinha) {
+ if ( (galinha.x >= this.x && galinha.x <= (this.x + this.width)) ||
+ (galinha.x + galinha.width >= this.x && galinha.x + galinha.width <= (this.x + this.width)) ) {
+ return (galinha.y >= this.y && galinha.y <= (this.y + this.height)) ||
+ ((galinha.y + galinha.height) < (this.y && this.height) && (galinha.y + galinha.height) > (this.y));
+ }
+ return false;
+ };
+ return result;
+ }
+
+
+
+ function desenharBitmap(bitmap,pos_x,pos_y,tamanho) {
+
+ for (var y in bitmap) {
+
+ for (var x in bitmap[y]) {
+
+ var valor = bitmap[y][x];
+
+ if (valor != 0) {
+
+ switch (valor) {
+
+ case 1: contexto.fillStyle = "black"; break;
+
+ case 2: contexto.fillStyle = "#aa0000"; break;
+
+ case 3: contexto.fillStyle = "#FCF926"; break;
+
+ }
+ contexto.fillRect(pos_x + (tamanho * x), pos_y + (tamanho * y), tamanho, tamanho);
+ }
+ }
+ }
+ }
+
+ var galinha = criarGalinha();
+ var lista_carros = new Array();
+
+ for (i = 0; i < 8; i = i + 1) {
+ if (Math.random() * 10 > 5) {
+ lista_carros.push(criarCarro(Math.random() * canvas.width, canvas.height / 10 * i, carro, -4));
+ } else {
+ lista_carros.push(criarCarro(Math.random() * canvas.width, canvas.height / 10 * i, carro_invertido, 4));
+ }
+
+ }
+
+
+
+ function draw() {
+
+ desenharFundo();
+
+ if (game_over) {
+ contexto.fillStyle = "red"
+ contexto.fillText("Matou a galinha :(!!!", canvas.width / 4, canvas.height / 2)
+ return;
+ }
+
+ for (var i in lista_carros) {
+ var carrinho = lista_carros[i]
+ desenharBitmap(carrinho.bitmap, carrinho.x, carrinho.y, 1)
+ }
+
+ desenharBitmap(galinha.bitmap, galinha.x, galinha.y, 1)
+ contexto.fillStyle = "black"
+ contexto.fillText(score, canvas.width / 2, 8)
+ }
+
+ document.onkeydown = function(event) {
+
+ console.log(event.which);
+ switch(event.which) {
+ case 38: galinha.move(-1); break;
+ case 40: galinha.move(1); break;
+ case 82 : chrome.runtime.reload(); break;
+ }
+ };
+
+ function testeFim() {
+ if (game_over == true) {
+ return true;
+ }
+
+ for (var i in lista_carros) {
+ if (lista_carros[i].pegouGalinha(galinha)) {
+ game_over = true;
+ return true;
+ }
+ }
+ return false;
+ };
+
+ setInterval(
+ function() {
+ for (var i in lista_carros) {
+ lista_carros[i].move();
+ }
+ game_over = testeFim();
+ draw();
+ }
+ ,50);
+ draw();
+
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-40917664-6', 'google.com');
+ ga('send', 'pageview');
+
+
+
diff --git a/MyChromeArduinoBlink/chrome-logo.svg b/FreeWay/chrome-logo.svg
similarity index 100%
rename from MyChromeArduinoBlink/chrome-logo.svg
rename to FreeWay/chrome-logo.svg
diff --git a/FreeWay/gamepad.png b/FreeWay/gamepad.png
new file mode 100644
index 0000000..0e2fe49
Binary files /dev/null and b/FreeWay/gamepad.png differ
diff --git a/FreeWay/main.html b/FreeWay/main.html
new file mode 100755
index 0000000..83847ac
--- /dev/null
+++ b/FreeWay/main.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FreeWay/manifest.json b/FreeWay/manifest.json
new file mode 100755
index 0000000..1b1065e
--- /dev/null
+++ b/FreeWay/manifest.json
@@ -0,0 +1,22 @@
+{
+ "name": "Atravesse a Galinha",
+ "version": "1.1",
+ "manifest_version": 2,
+ "minimum_chrome_version": "23",
+ "description": "Controls ship game with Arduino.",
+
+ "app": {
+ "background": {
+ "scripts": [ "background.js" ]
+ }
+ },
+
+ "icons": {
+ "16": "assets/icon-16x16.jpeg",
+ "128": "assets/chicken-icon.png"
+ },
+
+ "permissions": [
+ "serial"
+ ]
+}
diff --git a/FreeWay/styles.css b/FreeWay/styles.css
new file mode 100755
index 0000000..c737325
--- /dev/null
+++ b/FreeWay/styles.css
@@ -0,0 +1,40 @@
+body {
+ background-color: #f8f8f8;
+ font-family: "helvetica neue", helvetica, sans-serif;
+ font-size: 16px;
+
+}
+
+label {
+ display: block;
+ padding: 20px;
+ border-bottom: solid 1px #ddd;
+ border-right: solid 1px #ddd;
+ width: 300px;
+}
+
+label {
+ color: #999;
+}
+
+#drawRegion {
+
+}
+#port-picker,
+#status {
+ color: #000;
+}
+
+#port-picker {
+ max-width: 250px;
+ margin-right: 10px;
+}
+
+
+
+#container {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 640px;
+}
diff --git a/MyChromeArduinoBlink/styles.css b/MyChromeArduinoBlink/styles.css
deleted file mode 100755
index b59a66c..0000000
--- a/MyChromeArduinoBlink/styles.css
+++ /dev/null
@@ -1,84 +0,0 @@
-body {
- background-color: #f8f8f8;
- font-family: "helvetica neue", helvetica, sans-serif;
- font-size: 16px;
- overflow: hidden;
-}
-
-label {
- display: block;
- padding: 20px;
- border-bottom: solid 1px #ddd;
- border-right: solid 1px #ddd;
- width: 300px;
-}
-
-label {
- color: #999;
-}
-
-#port-picker,
-#status {
- color: #000;
-}
-
-#port-picker {
- max-width: 250px;
- margin-right: 10px;
-}
-
-#position-input {
- display: block;
- -webkit-appearance:none !important;
- width: 90%;
- margin: 20px auto;
- height: 6px;
- background: rgb(13, 168, 97);
-}
-
-#position-input::-webkit-slider-thumb {
- -webkit-appearance:none !important;
- width: 30px;
- height: 30px;
- border-radius: 15px;
- background: rgb(67, 135, 253);
-}
-
-#image {
- position: absolute;
- right: 10px;
- top: -10px;
- background-image: url(chrome-logo.svg);
- background-size: contain;
- background-repeat: no-repeat;
- background-position: center;
- width: 256px;
- height: 256px;
- -webkit-transition: all .2s linear;
-}
-
-#container {
- position: absolute;
- top: 0;
- left: 0;
- width: 640px;
-}
-
-#tv {
- position: absolute;
- bottom: 0;
- right: 0;
- width: 640px;
- height: 480px;
- border-left: solid 1px #ddd;
-}
-
-#tv video,
-#tv img {
- display: none;
-}
-
-#tv.working video,
-#tv.broken img {
- display: block;
-}
\ No newline at end of file
diff --git a/Simple Gamepad/Arduino Src/ArcaduinoJoystick/ArcaduinoJoystick.ino b/Simple Gamepad/Arduino Src/ArcaduinoJoystick/ArcaduinoJoystick.ino
new file mode 100644
index 0000000..86e4e1c
--- /dev/null
+++ b/Simple Gamepad/Arduino Src/ArcaduinoJoystick/ArcaduinoJoystick.ino
@@ -0,0 +1,48 @@
+
+// set pin numbers:
+const int buttonUp = 4; // the number of the pushbutton pin
+const int buttonDown = 5; // the number of the LED pin
+const int buttonLeft = 5; // the number
+const int buttonRight = 4; // the number
+const int led = 8;
+
+// variables will change:
+int buttonState = 0; // variable for reading the pushbutton status
+int ledState = 0;
+
+void setup() {
+ // initialize the LED pin as an output:
+ // pinMode(ledPin, OUTPUT);
+ Serial.begin(9600);
+ pinMode(buttonLeft, INPUT);
+ pinMode(buttonRight, INPUT);
+ pinMode(led, OUTPUT);
+
+}
+
+void loop(){
+ while(Serial.available() > 0) {
+
+digitalWrite(led, ledState);
+ buttonState = digitalRead(buttonLeft);
+ printState(buttonState);
+ buttonState = digitalRead(buttonRight);
+ printState(buttonState);
+
+
+ Serial.print("x");
+ delay(10);
+ ledState = Serial.read();
+
+ }
+
+
+}
+
+void printState(int buttonState) {
+ if(buttonState == HIGH) {
+ Serial.print(1);
+ }else {
+ Serial.print(0);
+ }
+}
diff --git a/Simple Gamepad/ChromeBlink.sublime-project b/Simple Gamepad/ChromeBlink.sublime-project
new file mode 100644
index 0000000..2c63c08
--- /dev/null
+++ b/Simple Gamepad/ChromeBlink.sublime-project
@@ -0,0 +1,2 @@
+{
+}
diff --git a/Simple Gamepad/ChromeBlink.sublime-workspace b/Simple Gamepad/ChromeBlink.sublime-workspace
new file mode 100644
index 0000000..5ff49ee
--- /dev/null
+++ b/Simple Gamepad/ChromeBlink.sublime-workspace
@@ -0,0 +1,358 @@
+{
+ "auto_complete":
+ {
+ "selected_items":
+ [
+ ]
+ },
+ "buffers":
+ [
+ {
+ "file": "manifest.json",
+ "settings":
+ {
+ "buffer_size": 403,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "blink.js",
+ "settings":
+ {
+ "buffer_size": 2454,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "background.js",
+ "settings":
+ {
+ "buffer_size": 191,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "main.html",
+ "settings":
+ {
+ "buffer_size": 552,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "README.md",
+ "settings":
+ {
+ "buffer_size": 886,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "styles.css",
+ "settings":
+ {
+ "buffer_size": 1275,
+ "line_ending": "Unix"
+ }
+ }
+ ],
+ "build_system": "",
+ "command_palette":
+ {
+ "height": 0.0,
+ "selected_items":
+ [
+ ],
+ "width": 0.0
+ },
+ "console":
+ {
+ "height": 0.0
+ },
+ "distraction_free":
+ {
+ "menu_visible": true,
+ "show_minimap": false,
+ "show_open_files": false,
+ "show_tabs": false,
+ "side_bar_visible": false,
+ "status_bar_visible": false
+ },
+ "file_history":
+ [
+ "/Users/brenoaraujo/git_repos/chromeapps/app/2013/qconsp/scripts/md/slides.md",
+ "/Users/brenoaraujo/git_repos/chromeapps/app/2013/qconsp/scripts/md/base.html",
+ "/Users/brenoaraujo/git/GdgFcsl/index.html",
+ "/Users/brenoaraujo/git/motionjs/manifest.json",
+ "/Users/brenoaraujo/git/motionjs/js/motion.js",
+ "/Users/brenoaraujo/git/motionjs/comm.html",
+ "/desenvolvimento/Chrome Extensions/Hello World/popup.html",
+ "/desenvolvimento/Chrome Extensions/Hello World/Manifest.json"
+ ],
+ "find":
+ {
+ "height": 35.0
+ },
+ "find_in_files":
+ {
+ "height": 0.0,
+ "where_history":
+ [
+ ]
+ },
+ "find_state":
+ {
+ "case_sensitive": false,
+ "find_history":
+ [
+ "text_endereco_ib",
+ "