For some reason my code isn't working. Only 1 item in the array has the value 1 when the space is pressed, but for some reason it is drawing the whole grid of items.
I would be very grateful if someone could help :)
here is my code (The problem lies in the draw_world function)
Just copy and paste it then run it.
Thanks
I would be very grateful if someone could help :)
here is my code (The problem lies in the draw_world function)
Just copy and paste it then run it.
Graphics 800,600 SetBuffer BackBuffer() Global world_x = 0 Global world_y = 0 Global world_width = 800 Global world_height = 600 Global grid_x = 0 Global grid_y = 0 Global grid_width = 9 Global grid_height = 9 Global tile_size = 50 Global cursor_x = 0 Global cursor_y = 0 Dim world(world_width-1,world_height-1) For x=0 To world_width-1 For y=0 To world_height-1 world(x,y)=0 Next Next While Not KeyHit(1) Cls user_control draw_world draw_grid Flip Wend Function draw_grid() For x=0 To grid_width For y=0 To grid_height Rect grid_x+x*tile_size,grid_y+y*tile_size,tile_size,tile_size,0 Next Next Color 0,0,255 Rect grid_x+cursor_x*tile_size,grid_y+cursor_y*tile_size,tile_size,tile_size,0 Color 255,255,255 End Function Function draw_world() For x1=0 To grid_width For y1=0 To grid_height For x2=0 To 10 For y2=0 To 10 If world(x2,y2)=1 Then Oval grid_x+x1*tile_size,grid_y+y1*tile_size,5,5 EndIf Next Next Next Next End Function Function user_control() If KeyHit(205) And cursor_x<grid_width Then cursor_x = cursor_x + 1 If KeyHit(203) And cursor_x>0 Then cursor_x = cursor_x - 1 If KeyHit(200) And cursor_y>0 Then cursor_y = cursor_y - 1 If KeyHit(208) And cursor_y<grid_height Then cursor_y = cursor_y + 1 If KeyHit(57) Then world(0,0)=1 End Function
Thanks