Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Help with simple problem.

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Apr 2004 17:42
Hello. I am not exactly new to Dark Basic, I have been dabbling with it for years, but mainly doing graphics for a fellow coder while he codes. I am currently trying to write a simple puzzle style game similar to mahjong in concept and am having difficulties quite early on . My mind just seems blank at the mo! I cannot seem to think how I can get the program to remember which tile you have clicked on, and compare it with the next one you click on. So that I can reset the tile selections or move to the check for if they match and if the move is legal.
I can see I am going to struggle with this for a while, so would like some pointers if possible. I nknow I have to store the tiles clicked into another array so I can check on them, but am just tearing my hair out at the minute!
Here is the code I use to select the tiles.

for n=1 to 36
if mousex()>boxclick(n,1) and mousex()<boxclick(n,1)+64
if mousey()>boxclick(n,2) and mousey()<boxclick(n,2)+64
if mouseclick()=1
boxsave(n)=boxclick(n,4)
texture object n,boxclick(n,4)+18
if boxclick(n,5)=0
play sound 1
boxclick(n,5)=1
inc tilecount
endif
endif
endif
endif
next n

The boxclick array has the values 1:x co-ord, 2:y co-ord, 3: object number
4:object texture, 5: if object has been clicked on once. If that helps you understand what I have done so far.

At the moment I can click on any tile and it will change the picture. I need to only be able to click on 2 tiles before the picture reverts back to the original or deletes the tiles. How can I store the tiles? I will continue to work on it and hopefully someone can help me with an idea or little code snippet.
I don't want someone to write the game for me! Just give me an idea how I can store and check this either in the same loop or a new one.

Oh by the way the boxsave array was an attempt to save the tiledata to an array but I'm not sure i can do it like that. Well I am babbling now, can anyone help me?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Apr 2004 18:58
Ahh, you should check the array after clicking to look for the last clicked tile - like your code:

if boxclick(n,5)=0
play sound 1
boxclick(n,5)=1
inc tilecount
endif


What I'd do is check for 2 selected tiles and compare them - then decide what to do with them:



Note that it's untested, but it's along the right lines at least.


Van-B


The nature of Monkey was irrepressible!.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Apr 2004 20:30
Thanks, that has given me a jumpstart. I've got matching tiles to work now, just got to figure out how to plot a path through the grid now to check if they match and are a valid move.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Apr 2004 20:31
Oh and you come from Scotland? Not too far away from me then I'm from England. Not too far from Pincho actually.

Login to post a reply

Server time is: 2024-11-26 14:47:10
Your offset time is: 2024-11-26 14:47:10