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.

DarkBASIC Professional Discussion / Hex Grid Snap code for a bust a move like clone

Author
Message
StOrM3
21
Years of Service
User Offline
Joined: 24th Sep 2003
Location: Cyberspace
Posted: 16th Apr 2010 20:10
Hello,

Just wondering if someone could show me an example on how to place the balls you shoot up to the top of the screen in a bust a move clone, in a hex grid fashion.. I know you have to offset like every other line, half the size of the balls, but I have some errors, like once the balls are placed, sometimes they overwrite a ball that is already there, even when using collision detection.. Any code snippets that I could run on a ball that has been shot, and on collision or before collision, that I could call to help place the balls correctly, would be greatly appreciated..

Thanks,

Ken

[PKE] Pain Killa Entertainment(tm) [PKE]
Pain Brings Reality...
[PKE] Pain Killa Entertainment(tm) [PKE]
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Apr 2010 20:27
I've always wondered myself, the best way to do this - I'll see if I can come up with a little puzzle bubble clone as an example.


Health, Ammo, and bacon and eggs!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Apr 2010 17:44
Here you go...


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
StOrM3
21
Years of Service
User Offline
Joined: 24th Sep 2003
Location: Cyberspace
Posted: 18th Apr 2010 00:14
Van B,

first off thanks for the code, it is great to put this into an archive for future use... Once I understand it thoroughly that is... It has some of the pitfalls that so much of the other dbpro code that I have seen and tried to make sense of has.. #1.) Not documented well enough with comments.. #2.) Alot of the variables have meaningless names, which makes it extremely hard to follow what is going on.. #3.) It has bugs in it, like phantom balls, that have once been removed, but for some reason are still seen as being there, so my best guess is that they were for some reason not removed from the arrays correctly, now granted 99.9% of the time it works as it should but I did notice it acting up on like 3 balls that were no longer there.

I already have a complete working game I coded in GM 8.0 btw.. I am now trying to re-do it using Dark GDK, but the DbPro code is fine, if I can use / understand it, so I can convert it over... The main 2 Things I am trying to figure out is: #1.) I have the player arrow rotating already, and all the walls / elevator graphics displayed properly on the screen, and I already have the ball images loaded. So I need to figure out how to limit the rotation angle on the player arrow, so that it can't turn past 90 and -90, I guess the easiest method, would be to make 2 turn functions one for left and one for right, so I can then just check the angle for which key is being pressed and move if not 90/-90 if it is 90/-90 then don't move just return... Ok, so I solved that one on my own..

But, the other, is the way I am organizing the game is simply like this, when the player hits the down arrow launch the ball, starting from the player arrow tip, moving upward until it collides with another ball / wall / elevator, and when it collides with walls just reverse the horizontal direction, when it hits the elevator figure out the correct hex offset to position the ball snapped to x&y, and do the same on collision with another ball, with another function call checking for combos, which is simple I can do that, but for your info, my ball graphics are 40x40 so each grid spot Y will be Y/40*40 and the X will be based off of the Y MOD 2 to see if we are on an even row, if so, then offset the X += 20;

So I am somewhat well versed in how to do it, just not sure on some of the things... Also, I am going to try and make the main game loop as simple as I can, and put everything into functions, with local variables, only using global vars when absolutely necessary.

I don't want you to get the wrong Idea, I do greatly appreciate you taking the time to do this code for me, as there are not too many people that would basically write a complete game for you like that, I just wish I could understand it better... I am well versed in Basic / DBPro also, but you take alot of shortcuts, and variable names, and comments, shortcuts are ok, if you document them fully so that someone that doesn't understand why your are using 0.1 and 1.0 etc..

Thanks again Van, if you have time, it would be great if you could comment / change some variable names to this code, as I think it would help alot of people out..

Ken aka StOrM3

[PKE] Pain Killa Entertainment(tm) [PKE]
Pain Brings Reality...
[PKE] Pain Killa Entertainment(tm) [PKE]

Login to post a reply

Server time is: 2025-06-21 04:49:12
Your offset time is: 2025-06-21 04:49:12