Hey all i got a simple array here of climbers. I have to put in text on the screen who reached the top of the mountain first.
can you guys write me a block of code that searches through the array and puts what climber reached the top of the mountain first?
i also need to make a function where if the mouse presses on one of the climbers the color of that climber changes....this one is not that important though.
well here is my code and i hope you guys can help me as i will really appreciate it.
*** Press the space bar to move the characters up the mountain at various speeds and press R to reset the program
int climberCount = 5;
int ropeCount = 5;
Climber[] climbers = new Climber[climberCount];
Rope[] ropes = new Rope[ropeCount];
void setup() {
size(800, 600);
reset();
for (int i = 0; i < ropeCount; i++) {
ropes[i] = new Rope(100+150*i,100);
}
}
void draw() {
background(0);
scene();
ropes();
climbers();
}
void reset() {
for (int i = 0; i < climberCount; i++) {
climbers[i] = new Climber(75+150*i, 450, color(random(255), random(255), random(255)));
}
}
void scene() {
fill(160, 82, 45);
rect(0, 0, width, 600);
fill(0, 0, 255);
rect(0, 0, width, 100);
}
void ropes() {
for (int i = 0; i < ropeCount; i++ ) {
ropes[i].display();
}
}
void climbers() {
for (int i = 0; i < climberCount; i++ ) {
climbers[i].display();
}
}
void keyPressed() {
if (key == ' ' ) {
for (int i = 0; i < climberCount; i++) {
climbers[i].update();
}
}
if (key =='r') {
reset();
}
}
class Climber {
float xpos;
float ypos;
color c;
Climber(float tempXpos, float tempYpos, color tempC) {
i want to make a pokemon clone for my first game; for nostalgia purposes.
my question is can i just take this image and set it as background for the most part and adding collision areas for the houses and such since they are not going to move?
or do i have to crop each house out and place them individually?
my first map will be pallet town and it will be in its own class.
thanks for reading my post, looking forward to responses.
i have 3 images per direction of movement. i move with the WASD scheme.
i can only get my character to look as though i am moving in one direction can someone please help.
if someone can code out or just plain out give me hints or a direction to move in, so i can have 3 different images for up down left and right directions that would be insanely awesome.
oh btw i coded this by cutting out images i needed with gimp and labeling them player 0-2;
if someone can show me how to crop the images out from the sprite sheet with the processing language that would be cool too : )
my code is :
int numFrames = 3; // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];
void setup()
{
size(800, 600);
frameRate(3);
images[0] = loadImage("player0.jpg");
for (int i=0; i<numFrames; i++) {
String imageName = "player" + nf(i,1) + ".jpg";
images[i] = loadImage(imageName);
}
}
void draw()
{
background(255);
player();
controls();
}
void player() {
image(images[frame], playerX, playerY);
}
int playerY=800/2;
int playerX=600/2;
void controls() {
if (keyPressed) {
if (key == 'w') {
playerY-=5;
}
if (key == 'a') {
playerX-=5;
}
if (key == 's') {
playerY+=5;
}
if (key == 'd') {
playerX+=5;
frame = (frame+1) % numFrames; // Use % to cycle through frames
}
}
}
sprite sheet:
thanks any help/suggestions will be very much appreciated!