Results 1 to 10 of 10

Thread: making a game

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    8

    making a game

    Hi, i am doin some coursework and i need to know how to use arrays properly and how to insert values into it correctly. i think i need to use the for... loop.. or something like that. i have a strict deadline so plz reply asap!

    i am making a snakes and ladders game and the user needs to insert the position and size of 10 snakes and 10 ladders. the board will be an array, and i have created the array with 100 spaces.

    i am getting the input from the user 1 by 1, so the size of the snake is stored, and then its position, i then need to somehow put these values onto the board. the code i have so far is as following:


    For d = 1 To 100 'for all values in the array
    board(d) = 0 'turn them into 0
    Next d 'complete initialisation of array


    no_of_snakes = 10 'the number of snakes = 10
    no_of_ladders = 10 'the number of ladders = 10
    snakecount = 0 'set snake counter to 0

    Do Until snakecount = no_of_snakes
    Do
    size_of_snake = InputBox("Enter size of snake between 10 and 30 for snake number " & snakecount + 1)
    If size_of_snake < 10 Or size_of_snake > 30 Then
    MsgBox ("The size of the snake has to be between 10 and 30, please retry")
    End If

    Loop Until size_of_snake > 9 And size_of_snake < 31
    Do
    position_of_snake = InputBox("Enter start position of snake for snake number " & snakecount + 1)
    If position_of_snake < 11 Or position_of_snake > 99 Then
    MsgBox ("Invalid position, try again")
    End If
    Loop Until position_of_snake > 10 And position_of_snake < 100

    board(position_of_snake) = size_of_snake * -1
    snakecount = snakecount + 1
    Loop

    the orange bit is where i need help
    thank u
    Last edited by mrsingh; Apr 28th, 2005 at 12:36 PM.

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