Sign in to follow this  

Allegro Program Problem

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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[i][j].width = 50; playingField[i][j].height = 80; playingField[i][j].tl.x = 200 + (i * playingField[i][j].width) + (i*10); playingField[i][j].tl.y = 65 + (j * playingField[i][j].height) + (j*10); playingField[i][j].br.x = playingField[i][j].tl.x + playingField[i][j].width; playingField[i][j].br.y = playingField[i][j].tl.y + playingField[i][j].height; playingField[i][j].center.x = playingField[i][j].tl.x + (playingField[i][j].width/2); playingField[i][j].center.y = playingField[i][j].tl.y + (playingField[i][j].height/2); //draw the actual rectangle (filled or unfilled) if (playingField[i][j].filled == true) rectfill(screen, playingField[i][j].tl.x, playingField[i][j].tl.y, playingField[i][j].br.x, playingField[i][j].br.y, GRAY); else rect(screen, playingField[i][j].tl.x, playingField[i][j].tl.y, playingField[i][j].br.x, playingField[i][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!

Share this post


Link to post
Share on other sites

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this