xxxxxxxxxx
123
/// TEST - 01 ///
// Simple gravity //
//Platform_Grass
let map1 = { }
//Character
let hero = { }
function setup() {
createCanvas(1000, 1000);
map1.x = 250
map1.y = 500
map1.w = 700
map1.h = 50
hero.x = 250
hero.y = 500
hero.w = 40
hero.h = -100
hero.vx = 4
hero.vy = 5
}
// SIMPLE COLOUR WHEEL
function draw() {
background(135,206,235)
let orange = color(255, 204, 0);
let green = color(34,139,34);
let blue = color(135,206,235);
fill(green);
circle(25, 25, 45)
fill(orange);
circle(75, 25, 45)
fill(blue);
circle(125, 25, 45)
// SIMPLE MAP OJECT
fill(green);
rect(map1.x, map1.y, map1.w, map1.h, 250, 100, 100, 100);
fill(orange);
// THE HERO
rect(hero.x, hero.y,hero.w, hero.h ) ;
// HERO FALLING OFF EGDE //
// Ventre side
if (hero.x < map1.x) {
hero.y = hero.y + hero.vy;
}
if (hero.y > map1.y) {
hero.y = hero.y + hero.vy;
}
//Højre side
if (hero.x > map1.x + map1.w) {
hero.y = hero.y + hero.vy;
}
if (hero.y > map1.y) {
hero.y = hero.y + hero.vy;
}
if (hero.y > map1.y) {
hero.y = hero.y + hero.vy;
}
// RESPAWN
if(hero.y > 1000){
hero.y = 500;
hero.x = 500;
}
// CONTROL
if(keyIsDown(68)) {
hero.x = hero.x + 4;
}
if(keyIsDown(65)) {
hero.x = hero.x - 4;
}
if(keyIsDown(RIGHT_ARROW)) {
hero.x = hero.x + 4;
}
if(keyIsDown(LEFT_ARROW)) {
hero.x = hero.x - 4;
}
if(keyIsDown(87)) {hero.y = hero.y - 30
}
}