Match 3 code available as resource
by Isaac Barbosa · in Torque Game Builder · 08/17/2008 (12:28 pm) · 58 replies
Hello,
I have programmed a prototype (only one level of match 3 recognition) of a 8 x 8 grid match 3 game. I'm wondering if
1. May I be able to upload a TGB project as resource including source code? -question to GG staff-
2. Is somebody interested in getting this file?
Let me know to upload it.
PS. The only negative point is that the code is almost not commented since I still have the da habit of not comment my scripts.
I have programmed a prototype (only one level of match 3 recognition) of a 8 x 8 grid match 3 game. I'm wondering if
1. May I be able to upload a TGB project as resource including source code? -question to GG staff-
2. Is somebody interested in getting this file?
Let me know to upload it.
PS. The only negative point is that the code is almost not commented since I still have the da habit of not comment my scripts.
#42
11/25/2009 (9:14 am)
That's not a bug, it's a feature :) You are supposed to drag the mouse from one gem to another, clicking shouldn't work.
#43
By the way anybody has idea to give gravity thing to gems so gems can fall down , if bottom tiles are empty and create gems always on top of grid layer.
Thanks.
11/25/2009 (10:36 pm)
Ok...I can understand that.. thnx.By the way anybody has idea to give gravity thing to gems so gems can fall down , if bottom tiles are empty and create gems always on top of grid layer.
Thanks.
#44
Whats happeneing all? Its going to 1 month already but still I couldn't get my answer here. What happened to forum helping nature. I am really in trouble. I couldn't figure out how to give tiles sliding features , if below of tile is empty space(empty tile).
Please help me....
thnx
12/18/2009 (3:27 am)
Hi,Whats happeneing all? Its going to 1 month already but still I couldn't get my answer here. What happened to forum helping nature. I am really in trouble. I couldn't figure out how to give tiles sliding features , if below of tile is empty space(empty tile).
Please help me....
thnx
#45
I am trying to add tile drop feature to the tile so it can drop down to its down if down tile is empty. For this I am calling this function just after we get match tile in Board::checkMatches. But It doesn't work properly..
function Board::testGoDown(%this)
{
echo("++++++++++ GoingDown called +++++++++++++");
for(%a = 0; %a < %this.xCount; %a++)
{
for(%b = 0; %b < %this.yCount; %b++)
{
if(%this.pieces[%a,%b + 1] $= "" && %b + 1 < 7)
{
$testDB[%a,%b] = %this.pieces[%a,%b];
%this.pieces[%a,%b].safedelete();
%this.pieces[%a,%b] = "";
$testDB[%a,%b].moveTo(getWord(%this.getTileGridPosition(%a,%b+1),0),getWord(%this.getTileGridPosition(%a,%b+1),1),100,true,true);
$PiecesInPlay.remove($testDB[%a,%b]);
%this.pieces[%a,%b + 1] = $testDB[%a,%b];
$PiecesInPlay.add($testDB[%a,%b]);
%this.pieces[%a,%b + 1].arraya = %a;
%this.pieces[%a,%b + 1].arrayb = %b + 1;
}
}
}
}
Any idea how to acheive this...Pls help needed.
Thanks
12/18/2009 (3:39 am)
Hi Isaac,I am trying to add tile drop feature to the tile so it can drop down to its down if down tile is empty. For this I am calling this function just after we get match tile in Board::checkMatches. But It doesn't work properly..
function Board::testGoDown(%this)
{
echo("++++++++++ GoingDown called +++++++++++++");
for(%a = 0; %a < %this.xCount; %a++)
{
for(%b = 0; %b < %this.yCount; %b++)
{
if(%this.pieces[%a,%b + 1] $= "" && %b + 1 < 7)
{
$testDB[%a,%b] = %this.pieces[%a,%b];
%this.pieces[%a,%b].safedelete();
%this.pieces[%a,%b] = "";
$testDB[%a,%b].moveTo(getWord(%this.getTileGridPosition(%a,%b+1),0),getWord(%this.getTileGridPosition(%a,%b+1),1),100,true,true);
$PiecesInPlay.remove($testDB[%a,%b]);
%this.pieces[%a,%b + 1] = $testDB[%a,%b];
$PiecesInPlay.add($testDB[%a,%b]);
%this.pieces[%a,%b + 1].arraya = %a;
%this.pieces[%a,%b + 1].arrayb = %b + 1;
}
}
}
}
Any idea how to acheive this...Pls help needed.
Thanks
#46
also have a top down shooter with ai engine rpg engine , picture finding engine, and a fishing game engine in the works. anyone willing to work on a project let me know im the only 2d programmer at i7 :)
mike bailey
imagination 7 games
04/01/2010 (4:46 pm)
i have completed the match 3 engine, undergoing a major overhaul of code over 90% has changed now has dropping tiles when removed vertical, and horizontal. multiple matching, redone the whole match finding code. is very stable. im adding in some particle effects and game conditions and making everything changable by globals. this is for a company project but i might be able to release the base code for free or small fee. ill keep you guys posted. feel free to ask me any questions , just remember to get this where it is its hundreds of lines of code longer. so just snippets will not surfice. but i will provide guidance as much as possible.also have a top down shooter with ai engine rpg engine , picture finding engine, and a fishing game engine in the works. anyone willing to work on a project let me know im the only 2d programmer at i7 :)
mike bailey
imagination 7 games
#47
04/01/2010 (5:15 pm)
Wow Micheal that sounds pretty sweet! :) If you wrote the code and as long as they're ok with you sharing how it works with the community that'd be very sweet. Or you could look into making a kit out of it and maybe make a buck or two if it's well done. It's good to see anything new being worked on in TGB, seems like people aren't sharing as much as they maybe could be, or like they used to when TGB was younger..
#48
04/01/2010 (6:31 pm)
well i think its in part individuals on here dont get together to form teams. thinking casual games make no money. but actually they are quite more lucrative than 3d games as a team of 2 or 3. say you produce 4 games a year. each has the opprotunity of being published on 3 -4 portals even in the top 50 a game for that year can bring in easily 20,000 dollars. the sky is the limit if you design the game to multiple audiences. so after the first year you could be well on your way to having a small game company going. my thoughts with some numbers i found on the net :)
#49
04/03/2010 (8:37 am)
Sorry for being out of the thread. I just have abandonen TGB forums while stick on iTGB ones. I´m starting to think that games are not for me since I haven´t do any buck with this...
#50
07/03/2010 (8:43 pm)
Made an update... for better or worse. My only wish that it will help all who are new to Torquescript. Thanks.
#51
tdn.garagegames.com/wiki/Image:Gems.zip
07/04/2010 (7:59 am)
Hi Gavin, Thanks for the update, I can't find the gem images to download though?tdn.garagegames.com/wiki/Image:Gems.zip
#52
http://sites.google.com/site/indiegamelair/Games-Resource
07/05/2010 (5:05 am)
The artwork by Isaac can be found on page one of the replies... But, to save you time, I have decided to host the artwork here as well:http://sites.google.com/site/indiegamelair/Games-Resource
#53
07/06/2010 (4:54 pm)
Thanks Gavin, appreciated!
#54
I've follow the tutorial given but the gems are still unclickable.
Is there any solution for this?
11/24/2010 (8:10 am)
Hi there.I've follow the tutorial given but the gems are still unclickable.
Is there any solution for this?
#55
i tried deploying this game on the iPhone...it works very slow...lot of lag.
How can i fix this?
Thanks
05/16/2011 (1:55 am)
Hi all,i tried deploying this game on the iPhone...it works very slow...lot of lag.
How can i fix this?
Thanks
#56
08/06/2011 (9:27 pm)
I'm having the same problem as Muhd. I did the bugfixes offered in this thread, but the gems are still unclickable. I took out the mouse dragging feature, but I'm still unable to click to swap gems. Any suggestions?
#57
@Takara and Muhd - I haven't tried this code, but you should check to make sure no other scene objects are swallowing the touch input. Also check for any warnings or console errors.
08/06/2011 (9:38 pm)
@Yash - The best way to resolve the speed is to port whatever you can to C++. Also, try to reduce the update callbacks by switching to controlled schedules.@Takara and Muhd - I haven't tried this code, but you should check to make sure no other scene objects are swallowing the touch input. Also check for any warnings or console errors.
#58
//Make sure the gem piece will be able to react to mouse clicks
$board.pieces[%a,%b].setUseMouseEvents(true);
Also in game.cs in the startGame function:
sceneWindow2D.setUseObjectMouseEvents(true);
The only error I'm getting in the console is related to the DirectInput joystick. It says: "DirectInput joystick failed to enable!"
Also, I've had to comment out this mouse-related block of code. Could that be the problem? This was what I commented out:
function gem::onMouseEnter(%this, %modifier, %worldPosition, %clicks)
{
if($justSwapped) return; //prevent clicking while swapping is still happening
/*
//Ensure the gems we are swapping are actually next to each other
if(t2dVectorDistance(%this.getPosition(), ($swapPreviousX SPC $swapPreviousY)) > $gemSize + 1)
{
error("gem swap malfunction!" SPC t2dVectorDistance(%this.getPosition(), ($swapPreviousX SPC $swapPreviousY)));
return;
}
%this.moveTo($swapPreviousX, $swapPreviousY, %speed, true, true);
$swapPreviousGem.moveTo($swapForThisX, $swapForThisY, %speed, true, true);
*/
}
If I uncomment the above code, I get these errors:
- t2dVectorDistance() - Invalid number of parameters!
- t2dSceneObject::moveTo() - Invalid number of parameters!
game/gameScripts/gem.cs (line number): Unable to find object: '' attempting to call function 'moveTo'
08/07/2011 (6:34 am)
Other than the gem::onMouseDown function in gem.cs, the only other instance of a mouse-related event is in board.cs which sets all of the gem pieces to be clickable once they are generated on the board://Make sure the gem piece will be able to react to mouse clicks
$board.pieces[%a,%b].setUseMouseEvents(true);
Also in game.cs in the startGame function:
sceneWindow2D.setUseObjectMouseEvents(true);
The only error I'm getting in the console is related to the DirectInput joystick. It says: "DirectInput joystick failed to enable!"
Also, I've had to comment out this mouse-related block of code. Could that be the problem? This was what I commented out:
function gem::onMouseEnter(%this, %modifier, %worldPosition, %clicks)
{
if($justSwapped) return; //prevent clicking while swapping is still happening
/*
//Ensure the gems we are swapping are actually next to each other
if(t2dVectorDistance(%this.getPosition(), ($swapPreviousX SPC $swapPreviousY)) > $gemSize + 1)
{
error("gem swap malfunction!" SPC t2dVectorDistance(%this.getPosition(), ($swapPreviousX SPC $swapPreviousY)));
return;
}
%this.moveTo($swapPreviousX, $swapPreviousY, %speed, true, true);
$swapPreviousGem.moveTo($swapForThisX, $swapForThisY, %speed, true, true);
*/
}
If I uncomment the above code, I get these errors:
- t2dVectorDistance() - Invalid number of parameters!
- t2dSceneObject::moveTo() - Invalid number of parameters!
game/gameScripts/gem.cs (line number): Unable to find object: '' attempting to call function 'moveTo'
Torque Owner Playware
Playware Studios
Sorry I forgot to intialize $gemsize. Its working now. But still one bug is there. Once you select gem by clicking on it and try to mouse over another gem (not adjacent tile) bit far tile(going thorugh outside of tile map) it hang (it does not do anything).
....thnx...