We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm supposed to create a program for my CST class using images. I'm using arrays and I figured out how to atleast display one player's cards and have it randomize. here is my code.
PImage[] images = new PImage[13];
int imageIndex = 0;
void setup(){
size(500,500);
background(255);
// load images into array
// images from freeware.esoterica.free.fr
//
// loading images into an array from an array of filenames
String[] filenames = {"c1.png","c2.png","c3.png","c4.png","c5.png","c6.png","c7.png","c8.png","c9.png","c10.png","cj.png","ck.png","cq.png"};
for (int i = 0; i < filenames.length; i++) {
images[i] = loadImage(filenames[i]);
}
}
void draw(){
//displays first image
image(images[imageIndex],0,0);
}
void mousePressed(){
//Get a new card when the mouse button is clicked
imageIndex = int(random(images.length));
}
How do I make a second deck of cards, and have that player be the computer's cards? How do I set up arguements and make it so that the higher number/card would win?
Answers
Can you edit your post to properly format your code?
It's hard to answer general "how do I do this" type questions, other than by pointing you to google and the Processing reference. What exactly are you confused about?
See Processing forum rules and advices
Had to format code and to move to proper category.
This is more effort than I was expecting. I'm done. Do what you can with this.
Another good thread about pack of cards: O:-)
http://forum.processing.org/two/discussion/2801/picking-cards-at-random-then-excluding-those-from-further-picking-
Full code solutions are academic dishonest and can get students a failing grade or even kicked out of school.
True re: full code solutions. But some people need them to learn. Sometimes a line or two of code from the exaple tells the researcher what to do., and can make their program work But an instructor isnt stupid. He/she gets to know what a student can do and when he/she has been driving a chevy and then turns up in a cadillac the instructor knows. If the student can't come up with the methodology then there's trouble. I assume most people are honest. if they aren't then too bad for them. they WILL get caught. It's THEIR responsibility.
@waynewal This debate has been had before on this forum, to the point that teachers have begged us to be more strict about full code solutions. I don't think you're speaking as an instructor, so it's a bit unreasonable to assume what's easy or not for an instructor.
The point is that even without worrying about academic dishonesty, full code solutions also rob the original poster of working through the process of breaking down a problem into smaller pieces and then thinking through each piece one at a time, which is the real point of homework like this.
The original poster is now worse off than they were before they posted. If we're really here to help people and not just race to dump code, then that should bother us.