Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1784 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Member




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):
1  
2  
3  
4  
5  
6  
7  
8  
if(wait_frames == 0)
{
       tile1.hide();
       tile2.hide();
       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 Kernel


Medals: 164
Projects: 23
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.

Kev

Offline Serethos

Junior Member




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 Kernel


Medals: 164
Projects: 23
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.

Kev

Offline Serethos

Junior Member




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 Member




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:

http://www.site.uottawa.ca/~nkana059/mediator/index_files/frame.htm

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 Member




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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (12 views)
2014-09-21 02:42:18

BurntPizza (11 views)
2014-09-21 01:30:30

moogie (13 views)
2014-09-21 00:26:15

UprightPath (23 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!