Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
billsnakes
billsnakes's Profile
1
Posts
3
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Square will not move in grid
[8 Replies]
02-May-2013 01:16 AM
Forum:
Programming Questions
I am a newbie in processing and I wish to move a square by using the arrow keys. Some of my code is below:
void keyPressed (){
if ((keyPressed == true) && (key == CODED)) {
if (keyCode == RIGHT) {
//if (directionX < 0)
directionX = 1;
directionY = 0;
println ("bush");
}
else if (keyCode == LEFT) {
//if (directionX > 0)
directionX = -1;
directionY = 0;
println ("lenin");
}
else if (keyCode == UP) {
//if (directionY < 0)
directionY = -1;
directionX = 0;
println ("high");
}
else if (keyCode == DOWN) {
//if (directionY < 0)
directionY = 1;
directionX = 0;
println ("low");
}
}
}
Where am I going wrong???
«Prev
Next »
Moderate user : billsnakes
Forum