|
This thread is locked; no one can reply to it. |
1
2
|
I'm new at this! |
luvzjetz16
Member #8,063
December 2006
|
hello everyone! I am trying to make a memory match game. So far I have created the game screen with all of the cards on it. However I'm havin some trouble trying to figure out three things: (1) How do I created the reverse side of the card and make it flip to the other side when clicked? (2) How do you activate the mouse on the screen so you can click the cards? (3) And is there anyway I can display a timer that will count down and stop the game when it gets to zero? |
miran
Member #2,407
June 2002
|
Quote: How do I create the reverse side of the card Well duh. You draw the back side in a bitmap editor. Then in-game instead of the face of the card you draw the back side. Quote: ...and make it flip to the other side when clicked? Check the values of mouse_x, mouse_y and mouse_b&1 and when they indicate a card has been clicked, play the flip animation. A simple way to do this is to progressively stretch the back side to a smaller size in one dimension and then when it reaches 0, progressively draw the face stretched to a bigger size until it reaches full size. Quote: How do you activate the mouse on the screen so you can click the cards?
install_mouse() Quote: And is there anyway I can display a timer that will count down and stop the game when it gets to zero? Yes. RTFM, the sections about timers and text output. -- |
William Labbett
Member #4,486
March 2004
|
Search the forums for "timers".
|
nonnus29
Member #2,606
August 2002
|
Welcome, jetzfan. Quote: (1) How do I created the reverse side of the card and make it flip to the other side when clicked? Sounds like you need to keep track of the card states somewhere; like have a int flipped_flag with possible values 0=facedown and 1=faceup. Quote: (2) How do you activate the mouse on the screen so you can click the cards? See Miran's post; installmouse(); There should be a program in the examples that uses the mouse, you can check that to see how it's done. Quote: (3) And is there anyway I can display a timer that will count down and stop the game when it gets to zero? Again, see the examples to see an example of using timers. |
luvzjetz16
Member #8,063
December 2006
|
ok if i can get the cards to flip over...how can i make them stay facing up if they are a match then flip back over if they don't make? can someone show me some code to do this? |
Simon Parzer
Member #3,330
March 2003
|
Quote: can someone show me some code to do this? C or C++? |
luvzjetz16
Member #8,063
December 2006
|
C |
Steve Terry
Member #1,989
March 2002
|
Hope that gives you an idea, I've commented out the code you are supposed to implement, but it should give you a framework to start with. ___________________________________ |
luvzjetz16
Member #8,063
December 2006
|
thank you very much....but how do you do this: I'm very sorry...I'm not good at this at all...like I said I'm very new at this! |
Steve Terry
Member #1,989
March 2002
|
There is a ton of ways to do it but here is my example:
Untested but I hope it gives you an idea, you go through each type of card and assign it to a random index of your array if it's not already taken. You have to do it twice because there are two of each card. This is just one way of doing it out of many. ___________________________________ |
luvzjetz16
Member #8,063
December 2006
|
am I doing this the right way...or is there a more simplier way to do this. I feel like i'm going about this the wrong way?! |
Steve Terry
Member #1,989
March 2002
|
Nothing in code happens magically, this is the way I know and it should work. If you want simpler than I suggest trying something else, get a good C book and read up on stuff before jumping into a graphical game environment. I'm not sure what you mean by simpler. ___________________________________ |
Simon Parzer
Member #3,330
March 2003
|
luvzjetz16, maybe you should post the code YOU have written so far. In your first post you say Quote: So far I have created the game screen with all of the cards on it. Could you post that code here? |
luvzjetz16
Member #8,063
December 2006
|
yep...here it is: #include <allegro.h> void init(); int main() { //before the game page there are two other pages that I have no problem with //game page BITMAP *img3, *cursor, *cursor2, *cursor3, *cursor4, *cursor5, *cursor6; img3 = load_bmp("c:\\familyguylogo.bmp",NULL); blit(img3, screen, 0,0,0,0,640,480); draw_sprite(screen, cursor, 50, 75); for(c=0;c<2000000000;c++); |
Steve Terry
Member #1,989
March 2002
|
Use the code mockup tags please. Have you ever heard of arrays? ___________________________________ |
luvzjetz16
Member #8,063
December 2006
|
yeah i've heard of arrays. what are mockup tags? |
Steve Terry
Member #1,989
March 2002
|
If you notice my code is in a scrollable text box, use: ___________________________________ |
Simon Parzer
Member #3,330
March 2003
|
OK, let me guess - before C you have written your programs in BASIC? My advice is to learn the language you are dealing with. You don't know about the basic features of C, so you are obviously stuck with no knowledge. That way you can say for (c=0;c<6;c++) { draw_sprite(screen,cursor[c],c*100,10); } or something like that. And instead of for(c=0;c<2000000000;c++); you can say (in Allegro) rest(2000); which will pause your game for exactly 2 seconds (2000 1/1000s of a second). Of course these are just basic concepts and they won't give you a memory game. You have a lot to learn. First try to cope with C, and then with Allegro. |
luvzjetz16
Member #8,063
December 2006
|
is this better?!
|
Steve Terry
Member #1,989
March 2002
|
Yes, nothing after system("cls") though? I don't know how you managed to get that to compile. ___________________________________ |
luvzjetz16
Member #8,063
December 2006
|
sorry it didnt copy and paste here it is:
this part is created for me when I opened an allegro C project in DEV C++ |
Steve Terry
Member #1,989
March 2002
|
Read Simons post, he said it best. I'm not sure I can help you much more. ___________________________________ |
luvzjetz16
Member #8,063
December 2006
|
ok guys....i've used Dev C++ for the past semester in college. I do know how to use arrays and things to make a memory game, but I don't know how to make that same game with just BITMAPS and sprites. |
nonnus29
Member #2,606
August 2002
|
Quote: I do know how to use arrays and things to make a memory game, but I don't know how to make that same game with just BITMAPS and sprites. You have to use both..... Make the game like you would with an array, then use allegro to give it a graphical interface. This is were the creativety comes into programming; to explain better would be to program it for you? |
Simon Parzer
Member #3,330
March 2003
|
Quote: (1) How do I created the reverse side of the card and make it flip to the other side when clicked? To answer your first question, just make variables. So for each card you have a variable "flipped" that indicates if the card is flipped or not. When the user clicks on one card you set flipped to 0 instead of 1. In your drawing code you have an if, or better said, several ifs.
You would save a lot of code by using a combination of structs and arrays, but you obviously can do without them. By declaring ~50 different variables at the beginning of your code. I did that once, and it was no fun. |
|
1
2
|