Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  To dumb creating Memory  (Read 2037 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Devvie

Java games rock!

« Posted 2003-09-27 18:38:52 »

i have a memory game applet. all works fine except of one thing.

imagine you have uncoverd two cards. now my game checks, wheter they are the same (and keep uncoverd) or not. if the two cards dismatch, i want that they keep uncovered for a few seconds so that the user can keep them in mind.

for that situation i need a counter (my counter counts frames)
if the counter is different to zero, the cards are locked and the uncovered ones keep open for this time.

now i have a problem. my only method, which is permanently calles, is an update() method, from my gamemanager class. it coordinates the painting-processes  of all cards and is called by paint-method of the applet-class.
therfore im forced to check or decrease the counter in this method.

so i have the following code snippet (pseudo code):
if(wait_frames == 0)
       tiles_locked = false;

paintAllTiles() ...

im not satisfied with this solution. not only, that in the "paint()" method i need to check every time, there are some traps in calling tileX.hide() every time again and again (btw.:    tile1 and tile2 keep references to the uncovered cards);

is there any elegant way to solve my problem ?

Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #1 - Posted 2003-09-27 18:45:15 »

let wait_frames run down to -1, then you won't have to keep calling hide() on your cards.


Offline Serethos

Junior Devvie

Java games rock!

« Reply #2 - Posted 2003-09-27 20:21:01 »

hmm, i didnt got the clue. where is the advantage to check for -1 ? where is the difference to zero ?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #3 - Posted 2003-09-28 06:13:19 »

Ycheck for 0 but you let the count role down to -1. Then your check for 0 will only get hit once and hence your hide() calls only once.

Possibly easier still would be to have a flag inside the tile saying whether its hidden or not. Then at the start of your hide method just return if its already hidden.


Offline Serethos

Junior Devvie

Java games rock!

« Reply #4 - Posted 2003-09-28 09:41:34 »

ok, now i got it.

but my tiles have a flag for being hidden or nor. but the difference is to know, wheter they are not hidden and shall stay so (two matching cards stay uncovered) or if they are not hidden bur shall cover in a few frames
Offline Rob Grzywinski

Junior Devvie

Reality Interactive

« Reply #5 - Posted 2003-10-07 11:56:16 »

Since I'm all about pushing patterns, use a Mediator.  A reference can be found at:

Unless of course you sleep with the GoF book under your pillow like me.

BTW:  what I just told you did nothing to actually help you with your problem.  I simply put a name to it.
Offline Serethos

Junior Devvie

Java games rock!

« Reply #6 - Posted 2003-10-12 19:18:17 »

ok, patterns are always a good idea. i have to read it fully, but btw. the page is catastrophical. it looks, as if someone converted a power point presentation to bad html ...
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (12 views)
2015-07-29 04:35:27

Riven (35 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (21 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (41 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (27 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!