Jump to content
  • Advertisement
Sign in to follow this  

Allegro Program Problem

This topic is 5053 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[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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!