Advertisement

Allegro Program Problem

Started by January 16, 2005 01:50 PM
-1 comments, last by destiny_breaker86 20 years, 1 month ago
I recently bought the book "Game Programming All In One 2nd ed." and I decided to try to make a clone of the card game from Final Fantasy 9 (Tetra Master). But I've come across a problem with the part where it fills some spots on the playing field (4x4 grid) so they can't be used. I was trying to get it to just randomly fill one spot for each column but for some reason it doesn't work. Here's the code: void screenSetup() { /****THIS IS THE PART THAT FILLS SOME OF THE CARDS****/ //then randomly pick one card from each column to be filled for(int k=0; k<4; k++) { int m = rand() % 4; playingField[k][m].filled = true; } //fill the playingField with spots for cards for(int j=0; j<4; j++) { for(int i=0; i<4; i++) { playingField[j].width = 50; playingField[j].height = 80; playingField[j].tl.x = 200 + (i * playingField[j].width) + (i*10); playingField[j].tl.y = 65 + (j * playingField[j].height) + (j*10); playingField[j].br.x = playingField[j].tl.x + playingField[j].width; playingField[j].br.y = playingField[j].tl.y + playingField[j].height; playingField[j].center.x = playingField[j].tl.x + (playingField[j].width/2); playingField[j].center.y = playingField[j].tl.y + (playingField[j].height/2); //draw the actual rectangle (filled or unfilled) if (playingField[j].filled == true) rectfill(screen, playingField[j].tl.x, playingField[j].tl.y, playingField[j].br.x, playingField[j].br.y, GRAY); else rect(screen, playingField[j].tl.x, playingField[j].tl.y, playingField[j].br.x, playingField[j].br.y, WHITE); } } } The playingField array is a structure of: struct COORD { int x, y; }; struct CARD_STATS { //top left, bottom right, and center coordinates COORD tl, br, center; int width, height; int color; bool filled; }; CARD_STATS playingField[3][3]; Some other strange things have also been happening with this code so maybe I just can't see it because I'm really just an amateur. Any help would be greatly appreciated!

This topic is closed to new replies.

Advertisement