Results 1 to 21 of 21

Thread: [RESOLVED] ellppm

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Resolved [RESOLVED] ellppm

    Hi,
    so ive
    Attached Images Attached Images  
    Last edited by pmcg123; Dec 14th, 2017 at 03:57 PM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    Well, you must have started somewhere. First off, is this a windows application, or is this just console? As far as the design goes, it could be either one, but a windows form would allow you to show things such as the cells (you could output the array to a listbox, for instance).

    Regardless of whether it is forms or console, you need to create an array of integer with size 100. This will need to be at class scope (or form scope if this is a forms application). You'd also want to create a Random object at the same scope. You will use the Random object to get a variety of things.

    There will be some initial method, which will likely be Sub Main for a console application, or the Load event for a Forms application. The Load event is a poor choice, but it is the most common one used for Forms applications while in school. In whatever method is right for the type of program, you will do these steps:
    Code:
    Dim count as Integer
    
    'Create the snakes.
    Do While count < 10
     'Choose a random location (0 to 100).
     'If the random location is 0, then choose a random number from 10 to 30 (10 to 31), make it negative, and put it in the location.
    Loop
    
    count = 0
    'Create the ladders.
    Do While count < 10
     'Choose a random location (0 to 100).
     'If the random location is 0, then choose a random number from 10 to 30, and put it in the location.
    Loop
    Technically, the instructions are that the number for the snakes or the ladders must lie between 10 and 30, which suggests that it actually has to be 11 through 29, but it could also be read as including both 10 and 30, which seems more reasonable, to me.

    Anyways, those steps would set up the array. What you do beyond that is up to you.
    My usual boring signature: Nothing

  3. #3
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Snakes and ladders game, PLEASE help

    Based on the size of the assignment and that you are unaware of how to even start, I strongly urge you to find some local help. If you have absolutely no clue where to start, I think it will probably take more than week for this thread to work you through the concepts. You have 2 days. There's probably a person in your class you can make friends with and get some help from. If not, find one. Donuts and other food offerings are always a good ice breaker.

    This assignment assumes you know how to use arrays, and probably basic console input/output. That also assumes you know some basics of String manipulation, and you're going to have to know how to parse String input into Integers. You will need to know looping constructs and If statements.

    If none of those sound familiar, open your book right now and start reading it intensely. Take notes. Enter the sample code. Get it running. Ask questions about any of those particular topics, but if you know zero basics it's very hard to start: you can accidentally end up asking about long division before you've learned addition.

    Shaggy Hiker gave good starting advice but missed one bit: you are not using the Random class to generate the snakes and ladders, the assignment asks you to input those snakes and ladders.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    I did see that, but I interpreted "input" rather loosely. I suspect that you are correct in your interpretation, more boring though it may be. After all, randomly chosen values can make life much more interesting. I once played a game like this that was printed on the back of a box of Life cereal. You could follow various paths, moving forwards either one or two squares at a time (based on a coin flip). All the paths converged at one square with a Go Back To Start label. Obviously, you had to skip over that one, so you had to get to the square before it and get a two (you could only move one or two). A two would put you on the square beyond it, which was a skip forwards three, which took you to a skip forwards two....which took you to a Go Back To Start. In other words, The Game of Life was just an exercise in constant frustration!!!! What an awesome message for the youth of today.

    However, I agree with Sitten as far as finding somebody local. In two days time, we'd probably have to write it for you, which doesn't help anybody. I would also suggest cookies rather than donuts, lest the recipient notices the holes in your offerings.
    My usual boring signature: Nothing

  5. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Snakes and ladders game, PLEASE help

    Well, the first thing you need to do is declare an Integer array where the upper-bounds is 99 (since arrays in VB.NET are 0 based, 99 represents 100 values). You will then need to declare an Integer variable to keep track of the user's position. Then allow the user to "roll a die" which is essentially generating a random number between 1-6 using Random.Next to increment their respective position. After the die is rolled, check if the position needs to increase or decreased based on the value in relation to the Integer array declared earlier. Once the user's position is 100 (or greater) then they win.

    Here is a quick example:
    Code:
    Imports System
    Public Module Module1
    	Public Sub Main()
    		'Prompt for the number of days to work
    		Dim days As Integer = 0
    		Console.Write("Days to Work: ")
    
    		'Loop until the user enters a valid number over 0
    		Do Until Integer.TryParse(Console.ReadLine(), days) AndAlso days > 0
    			'Display the error and re-prompt
    			Console.WriteLine("Please enter a valid whole number over 0.")
    			Console.Write("Days to Work: ")
    		Loop
    
    		'Keep a running total
    		Dim total As Integer = 0
    
    		'Use a conditional statement to increment the total by 3, 9, 27, and 81 if the days to work are respectively >= 1, 2, 3, 4
    		If days >= 1 Then
    			total += 3
    		End If
    		If days >= 2 Then
    			total += 9
    		End If
    		If days >= 3 Then
    			total += 27
    		End If
    		If days >= 4 Then
    			total += 81
    		End If
    
    		'Now loop from 5 to the number of days to work, if the upper-bounds is less than 5 then the loop won't execute
    		For counter As Integer = 5 To days
    			'Increment the running total by 50
    			total += 50
    		Next
    
    		'Display the running total as a currency
    		Console.WriteLine("Total: {0}", total.ToString("C"))
    	End Sub
    End Module
    Fiddle: Live Demo

    Edit - I see that some activity since I started this post
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  6. #6
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Snakes and ladders game, PLEASE help

    No one is reading the assignment. The assignment is not to "generate a board randomly and play a game of snakes and ladders", but to "allow a user to input values that will generate a board of snakes and ladders". All of the talk about dice and randomness is sending him down a road that leads to the answer to a different assignment.

    That said, dday9's example shows off a few things that are needed. In particular, his loop shows how to ask the user to input a number, with some demonstration of making sure that answer falls within a range.

    I'm going to try to write something that shows the basic concepts (in a different post), it's very hard to talk about homework assignments this simplistic without doing them outright. That won't help you.
    Last edited by Sitten Spynne; Nov 15th, 2017 at 11:13 AM.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  7. #7
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Snakes and ladders game, PLEASE help

    I have to assume you know some things like "how to declare a variable". You didn't show us any code or make an attempt, so I have to make assumptions like that. If you don't... odds of "success in the 1 remaining day" are slim.

    If I try to read your professor's mind, the point of this assignment is to see if you understand arrays and/or loops. Quick refresher.

    You should know how to create a single integer variable.
    Code:
    Dim three As Integer = 3
    Sometimes we want to make "many" variables at the same time. Imagine I have ten trucks that can each haul some number of apples, and I want to keep track of how many apples are in each. It would be tedious if I had to:
    Code:
    Dim truck1 As Integer = 745
    Dim truck2 As Integer = 896
    Dim truck3 As Integer...
    Arrays help us with this (very common) case. An "array" is one variable that represents MANY variables. Instead of "ten integer variables", I want "an array of ten integers". The way you declare an integer is similar to how you declare a normal variable:
    Code:
    Dim trucks(9) As Integer
    In English, this says, "Create an array of 10 Integer variables and name it 'trucks'." Why 10? This is a confusing bit that you have to get used to.

    Arrays in VB (and many computer concepts) start counting at 0. So if you have "3 items" in the array, they are numbered 0, 1, and 2. The number you put in parenthesis is not "the size of the array" but "the number of the last item I want".

    So the 'trucks' array is 10 Integers all named 'trucks'. You use parenthesis and the number to get and set the values of each array "element":
    Code:
    trucks(3) = 14
    trucks(0) = 12
    trucks(1) = trucks(3) + trucks(0)
    Console.WriteLine(trucks(1)) ' 26
    So making a 100-cell array is so easy I don't mind showing it to you, because it's already in front of you:
    Code:
    Dim gameBoard(99) As Integer
    That is 100 squares, where each square is represented by an Integer. Everything else you do in this application concerns asking the user for input, then changing values in this array based on that input.

    So let's move on to Console input. The topic's surprisingly deep but we only need the surface layer.

    Console.ReadLine() is your main tool. It waits for the user to push the Enter key, and will return everything they typed before it as a String.

    But we need Integers. So we have to know how to convert Strings to Integers. The easiest way to do so in our case is Integer.TryParse(). It looks like:
    Code:
    Function TryParse(ByVal input As String, ByRef output As Integer) As Boolean
    You give it a String. The second parameter is "ByRef", that means it is an OUTPUT parameter. If the String can be parsed to an Integer, then 'output' is set to the Integer and the function returns True. If it can't be parsed to an Integer, 'output' is set to 0 and the function returns False. So we can ask for an Integer like this, if we want:
    Code:
    Dim userNumber As Integer = 0
    
    Console.WriteLine("Enter a number!")
    Dim userInput As String = Console.ReadLine()
    If Integer.TryParse(userInput, userNumber) Then
        ' You have a number!
    Else
        ' You don't have a number!
    End If
    Usually you want to keep asking until you get a real number. To "keep asking", we need a loop. Deciding when to quit can be complex, which is why I prefer a loop that you have to break yourself. This is code that will not stop asking unless it gets a number between 100 and 200:
    Code:
    Dim userNumber As Integer = 0
    
    While True
        Console.WriteLine("Enter a number from 100 to 200:")
        Dim userInput As String = Console.ReadLine()
        If Integer.TryParse(userInput, userNumber) Then
            If userNumber >= 100 AndAlso userNumber <= 200 Then
                Console.WriteLine("Thanks!")
                Exit While
            Else
                Console.WriteLine("It has to be between 100 and 200!")
            End if
        Else
            Console.WriteLine("That isn't a number.")
        End If
    End While
    That is so close to what your assignment asks! It actually wants you to get 2 numbers: "where the head goes" and "how many spaces the player will move". So it's best to ask for and validate two values. That's not much different, you just need to read two values, then parse two values.
    Code:
    Dim headNumber As Integer = 0
    Dim snakeSpaces As Integer = 0
    
    While True
        Console.WriteLine("Enter the space where the snake's head should go.")
        Dim headInput As String = Console.ReadLine()
    
        Console.WriteLine("Now enter how many spaces it should move the player.")
        Dim spacesInput As String = Console.ReadLine()
    
        Dim isHeadValid As Boolean = Integer.TryParse(headInput, headNumber)
        Dim isSpacesValid As Boolean = Integer.TryParse(spacesInput, snakeSpaces)
    
        If isHeadValid AndAlso isSpaceValid Then
            ' HINT: you have to add something to the array here.
            ' HINT: you need to quit the loop if 10 have been added.
        Else
            Console.WriteLine("The inputs were not valid, try again.")
        End If
    End While
    Some things are missing from this, I'm afraid if I write too much more code I've "done the assignment for you". Programming is additive: part of the reason this assignment is confusing is you mentioned you failed the last. If you don't write and comprehend this exercise, the next one will be even harder. Let someone else write the assignments for you, and you're doomed.

    Here are the parts you need to figure out:
    • I showed you how to get the snake data, but you also need to get ladder data.
    • I left two "HINT" comments in the code for you to figure out.
    • The assignment specifies the "number of squares" part of each input set must be between 10 and 30, I did not validate that.
    • Pay close attention to the note that the "number of squares" you store for a snake must be negative.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Snakes and ladders game, PLEASE help

    At first glance, I thought they wanted an entire implementation of snakes and ladders, but after reading the OP's post 3 times, it's actually far simpler then everyone seems to be making it out to be. It's basically an app that asks for 20 pairs of numbers. This is like 10 to 20 minutes work. 2 days is more than enough time for the OP to complete it. Sitten and dday gave him everything he needs. If he can't do it with help from those examples, there he might have a deeper problem when it comes to understanding programming.

    @OP

    I was writing code far more complicated than this at 10 years old with no formal education in programming. Don't worry so much. Trust me, this is a very very easy assignment. If you really want to pass it, study Sitten's code carefully. Take the time to understand it and you should figure it out in no time. Ask more questions if you get stuck on something but make an attempt and post it so we can help you develop it properly.
    Last edited by Niya; Nov 15th, 2017 at 02:40 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  9. #9
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Snakes and ladders game, PLEASE help

    Quote Originally Posted by Niya View Post
    At first glance, I thought they wanted an entire implementation of snakes and ladders, but after reading the OP's post 3 times, it's actually far simpler then everyone seems to be making it out to be. It's basically an app that asks for 20 pairs of numbers...
    Well, he didn't post the whole exercise, so you can't see what the assignment entails past the (b) Interface paragraph.
    For the full text, you can check out this link..

    Aren't search engines phenomenal.

  10. #10
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Snakes and ladders game, PLEASE help

    that is awesome!
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  11. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Snakes and ladders game, PLEASE help

    Quote Originally Posted by passel View Post
    Well, he didn't post the whole exercise, so you can't see what the assignment entails past the (b) Interface paragraph.
    For the full text, you can check out this link..
    It's mostly modifying the original program slightly. It's still very simple though. The whole assignment is about a half hour of work at most.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #12

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Re: Snakes and ladders game, PLEASE help

    Thanks everyone for the help I have started to gain some understanding of arrays now to do this assignment however in my first post I did not realise that I left out a part of the question, this was:
    Name:  IMG_0780.jpg
Views: 305
Size:  85.7 KB
    So I actually have to simulate a single player game and show evidence of this, which I assume would suggest I also have to simulate a dice being rolled?

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    That's what the Random object will do for you. You create a Random object at form scope, then call the Next method like this:

    yourRandomObject.Next(1,7)

    This will pick a random number that will include the lower bound (1), but will not include the upper bound (7). So, that's your dice roll of 1-6.

    As for the simulation of one player, you have been left a whole lot of latitude as to how to do that. In fact, you have been left no way to win the game, exactly, so something is missing. After all, the final rule is that a roll that would take you off the board is ignored. So, what's the objective if not to get off the board? Is it to get to the final cell? To get within reach of the end? Not sure.

    One thing you'd be able to do is run the entire game simulation in a loop. If you did that, you could press a button for the simulation...and it would be over before you could get your finger off the button. All you'd be left with would be to see the steps. That seems boring, to me. So, what I would do would be to have a Start button, or something like that. Each time the button was pressed I'd do these things:

    0) Have an integer variable at form scope called something like PositionCounter.
    1) Get a random number between 1 and 6.
    2) Add that random number to PositionCounter.
    3) Add the value in the array at index PositionCounter to the PositionCounter. This will work because most cells hold 0, so you'd be adding 0, which is nothing. If the cell is either a snake head or a ladder foot, then the cell will have either a negative number (snake head), or positive number (ladder foot), and adding in that value will take you to the tip of the snake tail, or top of the ladder.
    4) Show the current value of the PositionCounter in a label.
    5) If you had landed on a snake head, have a second label that says something like "SNAKE Go Back X", or if it was a ladder foot have it say "LADDER, Advance X". The instructions don't require that, but it seems like it would be more interesting.

    You'd then keep pressing that button over and over, advancing and retreating, as the rolls, snakes, and ladders dictated, and at some point you'd reach the end of the array, at which point any further rolls would do nothing.
    My usual boring signature: Nothing

  14. #14

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Re: Snakes and ladders game, PLEASE help

    so how do i design the actual user interface of the game(position counter, board, snakes, ladders) and assign the array to each cell on the board?

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    I wouldn't even do that, unless it is somehow part of the assignment, and it isn't really clear that it IS a requirement. The assignment is a simulation of the game. Frankly, I'm not sure there's a good solution to creating the board that isn't FAR more work than anything discussed thus far. After all, my first thought was to handle the Paint event for the form, and in there, draw vertical and horizontal lines on the form to form the grid, then draw snake and ladder images at the grid cells where they are found, and draw some color circle as the player. You could then simulate the moves, but to do that effectively, you'd have to play with a bit of animation. Better still would be to put the grid on a panel that was on the form, or even a PictureBox, though a panel would work just as well. Then you could have a different background color for the panel. Since the grid is just vertical and horizontal lines, that could be formed using labels, rather than drawing it in the Paint event, but either one would work.

    The worse, but easier, option would be to form the grid using labels (set the backcolor to Black, and the width to 1 (vertical lines) or the height to 1(horizontal lines)), and in the spaces in the grid put pictureboxes. This would take 100 pictureboxes, though, and the performance would suffer greatly for having that many controls on a form. You could then put an image into each PB for a snake, a ladder, or the player. Still a fair amount of work, but less than the learning involved with using the Paint event....or maybe not, now that I think about it. The Paint event handler is probably easier.
    My usual boring signature: Nothing

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Snakes and ladders game, PLEASE help

    Quote Originally Posted by pmcg123 View Post
    so how do i design the actual user interface of the game(position counter, board, snakes, ladders) and assign the array to each cell on the board?
    This direction would take you more than 2 days if it's the first time you're doing something like this. Hell it would take me more than 2 days and I've done this kind of thing a lot. I could do it in less than a couple hours if I'm willing to settle on using straight lines as snakes and ladders, but anything more fancy is gonna take time and not necessarily for writing code only but developing the graphical assets in Paint or Photoshop to make it look good.

    Don't go down this road for your assignment with such time constraints. I would however recommend you do it as your own personal side project, that is if you actually have a real interest in programming. Projects like this can be fun and a great learning experience.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  17. #17
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Snakes and ladders game, PLEASE help

    I too, agree that putting a GUI on this makes it a 2-day project in and of itself. I see that the assignment was given on November 3, so maybe it's a possibility, but I guarantee you unless we completely do the work for you we can't teach you to make a GUI for Snakes and Ladders in the remaining... several hours.

    You have the tools you need to finish, go for a console application. If you want to do a GUI at least half of the code I posted won't work anyway.

    In the future:
    1. Start working on these assignments the moment you get them. Forum posts take days/weeks to resolve if you're struggling, and almost every programming task takes longer than you think.
    2. Post every question you have all at once, sometimes if we only have half the question we'll suggest things that make the other half harder.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  18. #18

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Re: Snakes and ladders game, PLEASE help

    Quote Originally Posted by Niya View Post
    This direction would take you more than 2 days if it's the first time you're doing something like this. Hell it would take me more than 2 days and I've done this kind of thing a lot. I could do it in less than a couple hours if I'm willing to settle on using straight lines as snakes and ladders, but anything more fancy is gonna take time and not necessarily for writing code only but developing the graphical assets in Paint or Photoshop to make it look good.

    Don't go down this road for your assignment with such time constraints. I would however recommend you do it as your own personal side project, that is if you actually have a real interest in programming. Projects like this can be fun and a great learning experience.
    Thanks for your help, I'm sure that since it is only beginners course the use of gui's wouldn't be necessary, but could you explain to me how I'd even present a simple board for the interface and even just use straight lines for the snakes and ladders? Looking like I'll be attempting an all nighters for this haha! I kind of understand how to use the arrays etc now but how could I use these for the game to simulate on a simple interface? What items from the toolbox should I use etc for designing the interface if you know what I mean.

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    Pretty much what I wrote would work. Ideally, you'd lay out 100 cells in a line, but that's pretty unlikely to fit well on a screen, so I was suggesting using a 10x10 grid. That many controls is likely too many. If you look at the e argument of the Paint event handler, you will see that it has a Graphics member. That, in turn, has DrawLine and DrawImage methods. You could use the DrawLine method to draw a grid on the form, then use the DrawImage to draw snakes where there are snakes, and ladders where there are ladders. You could then draw a filled ellipse as the player. Each cell, whether horizontal or in a grid, would be one index in the array. That can be determined mathematically. If you used PictureBoxes for all the cells, then you could put the array index into the .Tag property of the control, but drawing that many controls on the form would kill the performance. Doing the math to figure out the cell location based on an array index would be a bit more complicated, but it's just math.
    My usual boring signature: Nothing

  20. #20
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Snakes and ladders game, PLEASE help

    Quote Originally Posted by pmcg123 View Post
    ...but could you explain to me how I'd even present a simple board for the interface and even just use straight lines for the snakes and ladders?
    Well this is where experience comes in. You ask 10 people they would tell you 10 different ways to do this. Shaggy actually suggested one way by using controls. I would do it differently and yet someone else would do it differently to us. Point is, no way is wrong but some methods can actually produce better results than others.

    Shaggy's method is a neat and easy-ish way. My way wouldn't use a single control. I would just draw everything in the Paint event of a custom control and I'd put that control on a Form. Or you could draw directly onto the Form using the Form's Paint event, another thing Shaggy suggested. Individual experience would inform someone on how to do it.

    Quote Originally Posted by pmcg123 View Post
    What items from the toolbox should I use etc for designing the interface if you know what I mean.
    Right away here, you're thinking in terms of controls so arranging controls in a gridlike pattern might be best way for you to approach this until you get more experience with more advanced techniques. What Shaggy suggested with the Labels might be what you want.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  21. #21
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Snakes and ladders game, PLEASE help

    To be clear, I, too, favor doing things in the Paint event. That many controls would be painful in the designer and painful in practice, but it MAY be easier, simply because you may have experience dropping controls on a form. Drawing in the Paint event isn't difficult, but it would require a bit of math to do it nicely.

    Of course, to REALLY do it nicely would require quite a bit more drawing than what I suggested. I was saying that you should just draw a snake at the index where a snake head is located, but that wouldn't show the length of the snake. The same thing applies for ladders. A nicer approach would be to draw out the snake over the grid cells for the length of the snake, but that wouldn't be even possible, for me. I can't draw worth a darn, so I wouldn't even try that. Even drawing a ladder would be tough for me.

    Beyond that, I'd be using a timer to animate the player moves, but that's yet another layer of complexity on top of the design.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width