Lua programming question

  • #1, by nmvhFriday, 24. June, 07:30 A month ago
    Here's a question for the programmers. 

    Suppose I'm designing this simple puzzle, where a retangular grid of stone bricks must be manipulated by the player. There is one brick missing, and the player can always slide one of the bricks adjacent to the "empty brick space" into that space. In that way, the bricks can be moved around, until, for example, an image appears when the bricks are in their right place.
    I'm sure most of you have encountered this kind of puzzle, either in an adventure game or (as in my case) as a physical toy.

    When I start to design the puzzle in visionaire I find myself facing several hard decisisions. That's why any input from more experienced people is welcome.

    1) Can I augment the "brick objects" (which are technically just tables in Lua, right?) with, fow example, xPosition and yPosition (in the brick grid they belong to)?

    2) How should I store the info on where every brick is located, as well as the empty space?

    3) How ould I write the code so that much of the functions are reusable, as I'm having maybe 10-30 of these puzzles throughout the game?

    I realize there is no one correct answer. I guess what I'm asking is simply "how would you have done it?"

    Newbie

    38 Posts


  • #2, by afrlmeFriday, 24. June, 15:48 A month ago
    I haven't read your post, but I've already created & shared a template & tutorial ages ago for the dreaded sliding puzzles that everyone hates. You can find it here.

    Imperator

    7167 Posts

  • #3, by nmvhFriday, 24. June, 17:37 A month ago
    Too good to be true! smile Thanks a lot!!!

    Newbie

    38 Posts

Write post