Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Project Dead Sea-Bass
- #include "fbgfx.bi"
- screenres 640,480,32
- #define true 1
- #define false not( true )
- type door
- as integer x, y
- as integer is_open
- as uinteger color
- as integer switch_number
- as integer enabled
- end type
- type switch
- as integer x,y
- as uinteger color
- as integer door_number
- as integer enabled
- as integer player_number
- end type
- dim as door doorlist( 0 to 9 )
- dim as switch switchlist( 0 to 9 )
- ' Set up a door
- doorlist( 0 ).x = 5
- doorlist( 0 ).y = 5
- doorlist( 0 ).color = RGB(255,0,0)
- doorlist( 0 ).is_open = false ' true means its open
- doorlist( 0 ).enabled = true
- ' Set up a switch
- switchlist( 0 ).x = 7
- switchlist( 0 ).y = 8
- switchlist( 0 ).color = RGB(0,255,0)
- switchlist( 0 ).door_number = 1
- switchlist( 0 ).enabled = true
- switchlist( 0 ).player_number = 1
- ' Set up a switch
- doorlist( 1 ).x = 3
- doorlist( 1 ).y = 3
- doorlist( 1 ).color = RGB(255,0,0)
- doorlist( 1 ).is_open = false ' true means its open
- doorlist( 1 ).enabled = true
- switchlist( 1 ).x = 1
- switchlist( 1 ).y = 4
- switchlist( 1 ).color = RGB(255,255,255)
- switchlist( 1 ).door_number = 0
- switchlist( 1 ).enabled = true
- switchlist( 1 ).player_number = 2
- ' These will store our player coordinates
- ' We give these values later when we search the map for the player start position
- dim as integer player_x, player_y
- Dim as integer player2_x, Player2_y
- ' Our 10 by 10 grid for the map
- dim map( 0 to 9, 0 to 9 ) as Integer => { _
- {9, 9, 9, 9, 9, 9, 9, 9, 9, 9}, _
- {9, 0, 0, 9, 0, 0, 0, 0, 2, 9}, _
- {9, 3, 0, 9, 0, 0, 0, 0, 0, 9}, _
- {9, 0, 0, 0, 0, 0, 0, 0, 0, 9}, _
- {9, 0, 0, 9, 0, 0, 0, 0, 0, 9}, _
- {9, 9, 9, 9, 9, 0, 9, 9, 9, 9}, _
- {9, 0, 0, 0, 0, 0, 0, 0, 0, 9}, _
- {9, 0, 0, 0, 0, 0, 0, 0, 0, 9}, _
- {9, 1, 0, 0, 0, 0, 0, 0, 0, 9}, _
- {9, 9, 9, 9, 9, 9, 9, 9, 9, 9} _
- }
- ' The values in the map array mean the below things.....
- ' 0 = Floor
- ' 1 = Player start
- ' 2 = Exit
- ' 3= Player2
- ' 9 = Wall
- ' 10 = Door
- ' 11 = Switch
- ' 12 = Door
- ' 13 = Switch
- ' Finds the player start position in the map array
- '
- for map_y as integer = 0 to 9 ' Look at each row...
- for map_x as integer = 0 to 9 ' Look at each position in the row...
- if( map( map_x, map_y ) = 1 ) then ' If the map at this coordinate stores a 1...
- ' We found our player start position.
- player_x = map_x
- player_y = map_y
- exit for
- exit for
- end if
- next map_x
- next map_y
- for map_y as integer = 0 to 9 ' Look at each row...
- for map_x as integer = 0 to 9 ' Look at each position in the row...
- if (map (map_x, Map_y) = 3) Then
- Player2_x = map_x
- Player2_y = map_y
- exit for
- exit for
- end if
- next map_x
- next map_y
- ' These will hold where the player WANTS to go!
- dim as integer new_player_x, new_player_y
- dim as integer New_Player2_x, new_player2_y
- do ' Start our main game loop
- while inkey <> "": wend ' clear the key buffer
- new_player_x = player_x
- new_player_y = player_y
- new_player2_x = player2_x
- new_player2_y = player2_y
- ' See where the plater wants to go...
- if multikey (FB.SC_Right ) then new_player_x = player_x + 1
- If Multikey (FB.SC_left ) Then new_player_x = player_x - 1
- If Multikey (FB.SC_up ) THen new_player_y = player_y - 1
- If Multikey (FB.SC_down ) THen new_player_y = player_y + 1
- If multikey (FB.sc_w ) then new_player2_Y = player2_y - 1
- If Multikey (FB.SC_s ) THen new_player2_y = player2_y + 1
- if multikey (FB.SC_d ) then new_player2_x = player2_x + 1
- If Multikey (FB.SC_a ) Then new_player2_x = player2_x - 1
- ' Allow the player to "slide" along the walls
- ' If the player is able to move vertically then apply that to the player position
- if( map( player_x, new_player_y ) < 9 ) then
- player_y = new_player_y
- end if
- ' If the player is able to move horizontally then apply that to the player position
- if( map( new_player_x, player_y ) < 9 ) then
- player_x = new_player_x
- end if
- if( map( player2_x, new_player2_y ) < 9 ) then
- player2_y = new_player2_y
- end if
- ' If the player is able to move horizontally then apply that to the player position
- if( map( new_player2_x, player2_y ) < 9 ) then
- player2_x = new_player2_x
- end if
- 'for exit
- if( map( player_x, player_y ) = 2 ) AND ( map( player2_x, player2_y ) = 2 ) then
- print "nice"
- end if
- screenlock
- cls
- ' Draw the map on the screen
- for map_y as integer = 0 to 9
- for map_x as integer = 0 to 9
- ' c will store a colour
- dim as uinteger c
- ' Remember the values in the map array mean the below things.....
- ' 0 = Floor
- ' 1 = Player start
- ' 2 = Exit
- ' 9 = Wall
- ' 10 = Door
- ' 11 = Switch
- ' 12 = Door
- ' 13 = Switch
- select case map( map_x, map_y )
- case 0
- c = RGB( 0,0,0 )
- case 1
- c = RGB( 0,0,0 )
- case 2
- c = RGB( 255,255,0 )
- case 9
- c = RGB( 128,128,128 )
- end select
- ' Draw a coloured box depending on the map
- line ( map_x * 16, map_y * 16 )-step( 15, 15 ), c, BF
- next map_x
- next map_y
- ' cycle through all doors and switches
- for i as integer = 0 to 9
- ' this door is enabled so lets see if its open or closed
- if( doorlist( i ).enabled = true ) then
- ' Draw this door if its closed
- if( doorlist( i ).is_open = false ) then
- line ( doorlist( i ).x * 16, doorlist( i ).y * 16 )-step( 15, 15 ), doorlist( i ).color, B
- ' Edit the map and place a wall where this closed door is.
- map( doorlist( i ).x, doorlist( i ).y ) = 10
- else ' If the door is open...
- ' Edit the map and place a floor where this open door is.
- map( doorlist( i ).x, doorlist( i ).y ) = 0
- end if
- end if
- ' this switch is enabled so draw it
- if( switchlist( i ).enabled = true ) then
- ' Draw the switch
- circle ( switchlist( i ).x * 16 + 7, switchlist( i ).y * 16 + 7 ), 5, switchlist( i ).color
- if (switchlist (i).player_number = 1) then
- ' Are we standing on it??
- if( player_x = switchlist( i ).x ) AND ( player_y = switchlist( i ).y ) then
- doorlist( switchlist( i ).door_number ).is_open = true
- else
- doorlist( switchlist( i ).door_number ).is_open = false
- end if
- end if
- if (switchlist (i).player_number = 2) then
- ' Are we standing on it??
- if( player2_x = switchlist( i ).x ) AND ( player2_y = switchlist( i ).y ) then
- doorlist( switchlist( i ).door_number ).is_open = true
- else
- doorlist( switchlist( i ).door_number ).is_open = false
- end if
- end if
- end if
- next i
- ' Draw the player
- circle ( player_x * 16 + 7, player_y * 16 + 7 ), 4, RGB( 0, 255, 0 ),,,,F
- ' Draw our collision check (the place the player WANTS to go)
- circle ( new_player_x * 16 + 7, new_player_y * 16 + 7 ), 2, RGB( 0, 255, 255 ),,,,F
- Circle (player2_x * 16 + 7, player2_y * 16 + 7), 4, RGB (255, 255, 255),,,,F
- screenunlock
- sleep 70, 1 ' Deep sleep (ignore keypresses)
- loop until multikey( FB.SC_ESCAPE )
Add Comment
Please, Sign In to add comment