![]() |
|
[C#] Build game board with linked tiles - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Build game board with linked tiles (/showthread.php?tid=5515808) |
Build game board with linked tiles - JuicyProgramming - Jan 6, 2017 Hello, alright I wasnt sure about how to call this thread. I am having an assessment where I have to create a simple game. We have a board: Spoiler (Click to View) A board has 78 squares. Every square has a LeftSquare, RightSquare, UpSquare and DownSquare so it actually creates a path. But I am kinda clueless where to start. Solution I have thought of: Creating 78 square objects with coordinates as name. And setting the Left, Right etc in a big piece of code. But there must be a more efficient way. Anyone that has an idea? Let me know. Thanks! * - Owl - Jan 6, 2017 What about a 2d array? Elements at upper or lower bounds of either dimension will have direction limits. * - Zilog80 - Jan 6, 2017 Where are the 78 'squares'? Spoiler (Click to View) What are the rules of the game? * - JuicyProgramming - Jan 6, 2017 (Jan 6, 2017 10:46 AM)Zilog80 Wrote: Where are the 78 'squares'? Lmfao I cant count. Rules doesnt really matter. Players need to be able to walk with 1 pawn at the time. (Jan 6, 2017 10:08 AM)Orka Wrote: What about a 2d array? Elements at upper or lower bounds of either dimension will have direction limits. We have to use linked lists. * - Zilog80 - Jan 6, 2017 This is only a fast approach: You should define a 'square' class as follows: Code ID: int // Unique Id for that squareTake my numbered board game pic, square #2 should be: Code ID = 2;So, you are on square #2 and want to move: Code Press "A" or <- for moving to left:Surely there will be better approaches but that one should work. Let me know if you need more help. I could code some prototype (not pseudo-code like examples posted) if you are stuck. * - SIM-3081018 - Jan 6, 2017 What I would do is start with a map of some sort. A text file or image file which you'll read with the program, which translates positions in the map into positions on the screen. * - JuicyProgramming - Jan 6, 2017 (Jan 6, 2017 05:20 PM)Zilog80 Wrote: This is only a fast approach: This looks very good. Will look into it when I wake up. Thanks! * - Zilog80 - Jan 7, 2017 Fast prototype: ![]() Source: http://pastebin.com/a1PdjeaL Resource & Form dessign: https://imgur.com/a/aupvO The source code is self-explainatory. Anyway if you have any question let me know. The prototype could be improved a lot, but hope it helps 👍 * - JuicyProgramming - Jan 7, 2017 (Jan 7, 2017 05:37 AM)Zilog80 Wrote: -snip- Holy shit. This looks amazing. Thank you verry much! |