344
edits
(Created page with "Processing v3.0.1 Quellcode: <br> <source lang="java"> code </source><br>") |
No edit summary |
||
Line 4: | Line 4: | ||
<br> | <br> | ||
<source lang="java"> | <source lang="java"> | ||
PImage img; | |||
int x = 1, y = 0; | |||
color c = color(255, 255, 0); | |||
color wall = color(0); | |||
color ctrail = color(255, 0, 0); | |||
void setup() { | |||
size(344, 344); | |||
img = loadImage("Labyrinth.png"); | |||
noSmooth(); // nichts wird pixelig | |||
} | |||
void draw() { | |||
img.set(x, y, c); | |||
image(img, 0, 0, width, height); | |||
walk(); | |||
} | |||
void walk() { | |||
for(int i = 0; i < 3; i++);{ | |||
int xnew = x; | |||
int ynew = y; | |||
} | |||
} | |||
void keyPressed() { | |||
int xnew = x; | |||
int ynew = y; | |||
switch(keyCode) { | |||
case LEFT: | |||
xnew = x - 1; | |||
break; | |||
case RIGHT: | |||
xnew = x + 1; | |||
break; | |||
case UP: | |||
ynew = y - 1; | |||
break; | |||
case DOWN: | |||
ynew = y + 1; | |||
break; | |||
} | |||
if(img.get(xnew, ynew) != wall) { | |||
x = xnew; | |||
y = ynew; | |||
} | |||
} | |||
</source><br> | </source><br> |
edits