How do I create a 4 in a row game

0 favourites
  • 13 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi guys,

    Looking to create a game like this http://www.agame.com/game/4-in-a-row

    Have anyone ever created something like this?

    Thanks,

  • Found this to be an interesting challenge.

    It's just a basic version and it might contain bugs, but it mostly works as intended.

    The actual challenge was the win-detection algorithm.

    Here is the download to the .capx.

    It is by no means perfect, there are many ways to make the win-detection algorithms faster and more effective.

    Two things that I thought of:

    • The Array search area can be reduced to a 5x5 square with the last inserted coin as the center. There is no possible case where you insert a coin and win with a combination that is outside this area.
    • The check for vertical combinations should not check above the last placed coin since you can't place new coins under already placed ones.

    These features are easily implementable, but I didn't have the time to put them in.

    Hope this helps.

  • Hi randomly,

    It looks pretty good but there is a major issue. You will win if there is 4 in a row but there is a gap between them.

    R0J0hound would you be able to help?

    Thanks,

  • I have an example for detecting match (3 or 4) >>

    Works for horizontal & vertical match not diagonal but somehow you can just modify it to your needs.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • alextro,

    Your example is good but I am not sure how I can implement on the capx randomly provided. can you please give us some clarification?

    Thanks,

  • Perhaps I will start making this kind of tic-tac-toe game after the jam ended.

  • Fixed the horizontal check and improved vertical check.

    I was just thinking too complicated, trying to make smart loops, but could have instead just used brute-force conditions.

    Which I did now, inspired by alextro .

    Same link, different file: Download here

    One last thing that I need to figure out is, why the dictionary with the supposed check results always contains only one key when moving to the "win" layout.

    But that's not important.

    Important is that the main engine runs now.

  • Good but not perfect yet. I am still getting false wins

  • I'm not gonna dig any further into this, this is your project after all, not mine. ;)

  • Yes randomly has provided decent sample for everyone who want to learn the logic. It can be perfected by himself or other user by the time. At least he shown a good sample as starting point.

  • Users requesting help should be reminded of Tom's useful 'Tips for Posting' sticky, especially the first item:

    [quote:2a6whz78]1. We want to help, but we're not here to make your game for you. It's best not to ask too much!

    Some learning and development from the provided examples is always a good thing

    If a user is still stuck after trying to get what they want then it's best to post what you have done for others to check - they may spot simple errors much quicker that way.

  • As promised here my best attempt for tic-tac drop: https://www.dropbox.com/s/wgfhlw92p4w9z ... .capx?dl=0

  • alextro,

    wow. It looks great. I will try to implement the AI for the computer to play as the second player. thanks a lot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)