{ "cells": [ { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/javascript": [ "\n", " var component = document.getElementById(\"sketch_13\");\n", " if (component != undefined)\n", " component.remove();\n", " component = document.getElementById(\"state_13\");\n", " if (component != undefined)\n", " component.remove();\n", " component = document.getElementById(\"controls_div_13\");\n", " if (component != undefined)\n", " component.remove();\n", " require([window.location.protocol + \"//calysto.github.io/javascripts/processing/processing.js\"], function() {\n", " // FIXME: Stop all previously running versions (?)\n", " var processingInstance = Processing.getInstanceById(\"canvas_13\");\n", " if (processingInstance != undefined && processingInstance.isRunning())\n", " processingInstance.noLoop();\n", " });\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n", " Sketch #13:
\n", "
\n", "
\n", "
\n", " \n", " \n", " \n", " \n", "
\n", "Sketch #13 state: Loading...
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "class Bird {\n", " int x;\n", " int y;\n", " color bird_color;\n", " \n", " Bird(int x, int y, color bird_color) {\n", " this.x = x;\n", " this.y = y;\n", " this.bird_color = bird_color;\n", " }\n", " void draw() {\n", " fill(this.bird_color);\n", " ellipse(this.x, this.y, 10, 20);\n", " }\n", " void move() {\n", " this.x += 1;\n", " }\n", " void fly() {\n", " this.y -= 1;\n", " }\n", "}\n", "\n", "class Banana {\n", " int x;\n", " int y;\n", " \n", " Banana(int x, int y) {\n", " this.x = x;\n", " this.y = y;\n", " }\n", " void draw() {\n", " fill(color(255, 255, 0));\n", " ellipse(this.x, this.y, 10, 60);\n", " }\n", " }\n", "\n", "Bird bird0;\n", "Bird bird1;\n", "Bird bigbird;\n", "Bird bluejay;\n", "\n", "Banana the_banana;\n", "\n", "void setup() {\n", " bird0 = new Bird(10, 10, color(255, 0, 0));\n", " bird1 = new Bird(20, 10, color(0, 255, 0));\n", " bigbird = new Bird(40, 50, color(255, 255, 0));\n", " bluejay = new Bird(60, 70, color(0, 0, 255));\n", " the_banana = new Banana(50, 50);\n", "}\n", "\n", "void draw() {\n", " background(color(0, 128, 0));\n", " bird0.move();\n", " bird1.move();\n", " bigbird.move();\n", " bluejay.fly();\n", " \n", " bird0.draw();\n", " bird1.draw();\n", " bigbird.draw();\n", " bluejay.draw();\n", " \n", " the_banana.draw();\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Calysto Processing", "language": "java", "name": "calysto_processing" }, "language_info": { "codemirror_mode": { "name": "text/x-java", "version": 2 }, "file_extension": ".java", "mimetype": "text/x-java", "name": "java" } }, "nbformat": 4, "nbformat_minor": 0 }