Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
// This program will move an avatar to collect gold coins.
function preload() {
// Image is 50 x 50 pixels.
img = loadImage('https://i.imgur.com/AFfUFBS.png');
img2 = loadImage('https://i.imgur.com/vrVNQcW.png');
}
var x = 200; // initial x-coordinate for avatar
var y = 200; // initial y-coordinate for avatar
var c = 'white'; // initial avatar color
var s = 10; //initial avatar size
var coinSize = 10; // set size of coin
var coins = []; // the array to store the coin positions
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
for(var i = 0; i < 4; i++) {
for(var j = 0; j < 4; j++) {
coins.push(new Coin(80+i*80,80+j*80));
}
}
}
function draw() {
background(0);
image(img, 0, 0, width, height, 0, 0, img.width, img.height);
// Draw Coins
for(var i = 0; i < coins.length; i++) {
coins[i].display();
var d = dist(coins[i].x,coins[i].y,x,y)
var d2 = s/2 + coinSize/2;
if(d < d2) {
coins.splice(i,1);
s += 10;
}
}
// Draw Avatar
image(img2, x, y, s, s);
// Allow avatar to move
if(keyIsPressed) {
if(keyCode === UP_ARROW) {
y--;
} else if(keyCode === DOWN_ARROW) {
y++;
} else if(keyCode === LEFT_ARROW) {
x--;
} else if(keyCode === RIGHT_ARROW) {
x++;
}
}
}
// Object that stores positions of coins
function Coin(x,y) {
this.x = x;
this.y = y;
this.display = function() {
fill('yellow');
ellipse(this.x,this.y,coinSize);
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team