We are about to switch to a new forum software. Until then we have removed the registration on this forum.
PImage ship;
PImage iceberg;
void setup() {
size(758,403);
background(#43B3ED);
// Images of the game
ship = loadImage("ShipObject.png");
iceberg= loadImage("iceberg_object.png");
}
void draw() {
image(ship, 0, 52);
image(iceberg,250,52);
}
how do I move the ship with the "W" "A" "D" keys?
Answers
http://Studio.ProcessingTogether.com/sp/pad/export/ro.91tcpPtI9LrXp
https://www.Reddit.com/r/processing/comments/88hid4/keyboard_inputs_wasd_not_working_on/
well, currently you are drawing a ship at a constant position
you need to make that position variable... so add two variables, x and y...
Do some reading
since your task is to have a
class Ship {
, I suggest to do the tutorial on objectsit's very good.
https://www.processing.org/tutorials/objects/
read the first 5 tutorials too to get an understanding
https://www.processing.org/tutorials/
What you have to do
here you will learn that the object
ship
is displayed with x,y position2 variables instead of
0,52
should be in your class Ship.then on a key stroke say
x++;
ory++;
etc. to alter the position. E.g. in drawship.x++;
orship.y++;
etc.show your entire code then.
it's unwise that you start a new discussion on the same topic. it's also unwise that you deleted the homework description from the previous discussion
but we can lead you through
Best regards, Chrisir ;-)
see reference for keyPressed and key=='w' etc.
https://www.processing.org/reference/