How do I make Word Search game's horizontal, vertical and Diagonal highlighting lines.

Not favoritedFavorited Favorited 1 favourites
  • 12 posts
From the Asset Store
HTML5 Game Bundle (7 Games) – Created with Construct 3
  • my all logics are done for word search game except lines to highlight words. specially diagonal lines.

    I have created grid 10x10. touch start for first box and while is touching box calculating distance and angle. angle snap to 45 degree. my lines are not perfectly working

    I want to apply those lines similar to this game.

    myfile

    Tagged:

  • anyone??

  • Well you just need to search the keyword deeper. My example exist years ago to showcase that kind of game mechanic:

    dropbox.com/scl/fi/07ytwvrz4rvbnwbclu8w9/search_word_jumble.capx

  • yes I looked at your example few days ago but that doesn't have that feature I'm trying to implement. in your example the line is connecting to any block at any direction non-perfect diagonal too. that's not what I needed.

    however I was able to get help from Gemini.

  • Sure you can lock direction in 45 degree iteration or compare distance. So if player pick diagonal route then the next valid word queue position must had that same diagonal distance reference, if less it will be ignored. And it goes the same with horizontal or vertical pick.

  • What solution did you end up with?

    My first thought is you could mark all the squares horizontal, vertical from the start square and limit the end square to one of those.

    Pick cell by expression
    (Cell.x=start.x) | (cell.y=start.y) | (abs(cell.x-start.x)=abs(cell.y-start.y)
    Pick cell closest to touch.x,touch.y

    Alternately you could do some math to calculate the end tile on the closest 45 line.

    set ang to round(angle(start.x,start.y,touch.x,touch.y)/45)*45
    Set step to abs(ang)%45=0?cell.width:cell.width*sqrt(2)
    Set dist to round(((touch.x-start.x)*cos(ang)+(touch.y-start.y)*sin(ang))/step)*step
    
    Set endx to start.x+dist*cos(ang)
    Set ends to start.y+dist*sin(ang)

    Basically it finds the closest 45 degree line, then projects the touch position onto that, and rounds to the nearest cell.

    There may be a simpler solution too.

  • R0J0hound here is my discussion with Gemini.

    g.co/gemini/share/31655c57dd2c

    when I reached gemini limit then i used new chat for bug fixing

    g.co/gemini/share/cf6964988b78

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Whoa. Thats a lot of code. Hard to pick out the relevant parts. Well, as long as it works for your use case.

  • I made lines little complex. if you play web preview which gemini created first. try drag and hold and try drag at different direction. then you'll notice why code is lengthy. I think almost 70% code is Horizontal, Verticle, and Diagonal lines.

  • I mean at a glance it looks to be a long and complex solution. Probably can be simplified a lot. But that would require breaking it down to figure out exactly what it’s doing and why.

    But I guess I’m not a fan of llm ai code. Debugging, testing and cleaning up code is time consuming and I’d rather not do it if I can.

  • That sounds like a solid setup so far! I'm working on something similar and was wondering:

    How are you currently snapping the angle to 45 degrees? Are you using angleSnap = round(angle / 45) * 45 or something else?

    For diagonal lines, are you checking if both X and Y positions are changing equally to maintain a perfect diagonal?

    Also, are you using a single line object stretched and rotated between start and end points, or a tile-based approach for each grid cell?

    I’d love to know what your current method is and what’s going wrong — maybe we can figure out the cleanest way to make the line-drawing logic more precise.

  • How are you currently snapping the angle to 45 degrees? Are you using angleSnap = round(angle / 45) * 45 or something else?

    yes I'm snapping the angle at 45 degree with tolerance.

    For diagonal lines, are you checking if both X and Y positions are changing equally to maintain a perfect diagonal?

    for diagonal you need to check if grids(x) and grid(y) are equall (1,1).

    are you using a single line object stretched and rotated between start and end points, or a tile-based approach for each grid cell?

    I'm using 9patch, so that I can use corners round. you can use tiledBackground too.

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