-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwar.js
More file actions
42 lines (28 loc) · 662 Bytes
/
war.js
File metadata and controls
42 lines (28 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var char1 = new Char(300, 500, 50, 75);
function setup() {
createCanvas(600, 600);
}
function draw() {
background(0);
char1.afficher();
char1.bouger();
}
function Char(x, y, lo, la, ) {
this.x = x;
this.y = y;
this.lo = lo;
this.la = la;
this.afficher = function() {
rectMode(CENTER);
rect(this.x, this.y, this.lo, this.la);
}
this.bouger = function() {
if (keyIsDown(LEFT_ARROW)) {
this.x -= 3;
} else if (keyIsDown(RIGHT_ARROW)) {
this.x += 3;
}
if (this.x > 575) { this.x = 575 }
if (this.x < 25) { this.x = 25 }
}
}