Post by OddChild on Jun 9, 2006 15:19:34 GMT -5
If you copy and paste sidescroll.map into pit folder. this should work. Try playing around with the attributes. If you change the ground to non walkable, then you can walk on them.
This is just SLIGHTLY adapted for castle.map
option explicit
dim bRunning 'if this is false the game stops running
bRunning = True
' declare our image variables
dim stone, breakable, ladder, gem, box, obstacle(9), ladder_top, guy
' our game variables
dim current_level, total_obstacles, collected_gems, move_increment, pause_time, _
total_breakables, total_gems, total_levels, dest_x, dest_y
current_level = 1
dim viewx, viewy
dim guyx, guyy
dim bEnd_Level, bMoving
dim Font1
viewx = 0
Const dir_up = 200 : Const dir_down = 208 : Const dir_left = 203 : Const dir_right = 205
dim map_rows, map_cols, MyMap
map_rows = 8 : map_cols = 11
' our interactive objects in the scene; max ten of each
dim s_gem(10), s_obstacle(10), s_breakable(10)
'#############################################################################
Sub Main()
if (graphics.initialize <> True) then exit sub
dim temp
key.Initialize
Font1 = graphics.CreateFont("system", 14)
Graphics.MapInitialize
obstacle(0) = graphics.loadImage("obstacle.bmp")
breakable = graphics.loadImage("breakable.bmp")
guy = graphics.loadImage("guy.bmp")
guyy = 300
With graphics
.SetRows guy, 4 ' number of rows in the image
.SetCols guy, 2 ' number of columns in the image
.SetTotalFrames guy, 2 ' total images for one direction of animation
.SetAnimated guy, True ' tell the application to treat this as an animated image
.SetFrameWidth guy,32 ' the width of a single frame
.SetFrameHeight guy, 32 ' the height of a single frame
.setanimateLoop guy, True
.setxy guy, guyx, guyy
end with
Init
do while bRunning = True
if key.pressed(1) OR key.pressed(0)then bRunning = False
If bMoving = False then CheckInput ' move player if he is not already moving
graphics.clear 255
graphics.SetImage MyMap ' draw map
graphics.SetImage guy ' draw player
'
' check all of our obstacles
for temp = 1 to total_obstacles
' draw all our obstacles
graphics.SetImage obstacle(temp)
' see if it should fall
If graphics.mapGetAtt(graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32) = -1 then
'graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
'if its not moving...
If graphics.getautogoto(obstacle(temp)) = false then
' tell it how much and how fast to fall
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32, 500
' this space will soon be empty, so update the map
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
' update the map attributes to indicate the new position of the obstacle
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp))+32, 3
end if
end if
next
' check on player
' is he done making his move
If graphics.getautogoto(guy) = false then
'graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = false
' let him fall if blank space under him
If graphics.mapGetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = -1 then
MovePlayer(dir_down): bMoving = true
end if
end if
' if viewx + screenwidth > mapwidth then viewx = mapwidth - screenwidth
graphics.display
loop
key.terminate
graphics.terminate
end sub
'#############################################################################
Call Main
'#############################################################################
Sub Init() ' get ready to start a new round
' initialize our variables
bEnd_Level = False
InitMap(current_level)
'InitGems
'InitObstacles
'InitBreakables
end sub
'#############################################################################
Sub CheckInput()
If Key.Pressed(dir_up) then MovePlayer(dir_up)
If Key.Pressed(dir_down) then MovePlayer(dir_down)
If Key.Pressed(dir_left) then MovePlayer(dir_left)
If Key.Pressed(dir_right) then
MovePlayer(dir_right)
guyx = graphics.GetX(guy)
guyy = graphics.Gety(guy)
' if guyx > 300 then
viewx = viewx + 1
graphics.MapViewX viewx
graphics.mapupdate
' end if
end if
If graphics.getautogoto(guy) = false then ' not moving
graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = False
end if
end Sub
'#############################################################################
Sub MovePlayer(direction)
If graphics.getautogoto(guy) = true then exit sub ' already moving
Dim temp
Select Case direction
Case dir_up
graphics.setcurrentFrame guy, 1
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) - 32, 500
Case dir_down
If graphics.mapgetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = 0 then exit sub
graphics.setcurrentFrame guy, 5
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) + 32, 500
Case dir_left
' see if you are at a wall
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are pushing an obstacle (big stone)
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 3 then exit sub
graphics.setcurrentFrame guy, 7
graphics.setautogoto guy, graphics.GetX(guy) - 32, graphics.GetY(guy), 500
Case dir_right
' if your next to a wall, no move
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are up against an obstacle
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 3 then
' is there a blank space next to the obstacle so it can move?
If graphics.mapgetAtt(graphics.GetX(guy) + 64, graphics.GetY(guy)) = -1 then
' determine which obstacle we are up against
for temp = 1 to total_obstacles
If Graphics.getx(obstacle(temp)) = graphics.GetX(guy) + 32 then exit for
next
' go ahead and move the obstacle
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)) + 32, graphics.GetY(obstacle(temp)), 500
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1 ' where obstacle was is now clear
else
' can't push the thing, something blocking it
exit sub
end if
end if
graphics.setcurrentFrame guy, 3
graphics.setautogoto guy, graphics.GetX(guy) + 32, graphics.GetY(guy), 500
End Select
bMoving = True
graphics.setanimateTime guy, 125
end sub
'#############################################################################
Sub InitMap(thislevel)
dim width, height
dim x, y
total_obstacles = 0 : total_breakables = 0 : total_gems = 0 : collected_gems = 0
MyMap = graphics.mapload("sidescroll.map") ' load our precomposed map from its file
width = graphics.mapGetWidth() ' in pixels
height = graphics.mapGetHeight()' in pixels
for x = 1 to CInt(width/32) ' divide by tile width to convert to tile coordinates
for y = 1 to CInt(height/32) ' divide by tile height to convert to tile coordinates
Select Case graphics.mapGetAttC(x,y) ' get attribute via coordinates
Case 1
graphics.setXY guy, x *32, y * 32 ' set position in pixels
graphics.mapsetattc x, y, -1
Case 2
total_gems = total_gems + 1
Case 3
total_obstacles = total_obstacles + 1
obstacle(total_obstacles) = graphics.cloneImage(obstacle(0))
graphics.setXY obstacle(total_obstacles), x *32, y * 32 ' set position in pixels
Case 4
total_breakables = total_breakables + 1
End Select
next
next
end sub
'#############################################################################
The 2nd one is for sidescroll.map You need to edit the atributes to make the ground unwalkable....
option explicit
dim bRunning 'if this is false the game stops running
bRunning = True
' declare our image variables
dim stone, breakable, ladder, gem, box, obstacle(9), ladder_top, guy
' our game variables
dim current_level, total_obstacles, collected_gems, move_increment, pause_time, _
total_breakables, total_gems, total_levels, dest_x, dest_y
current_level = 1
dim bEnd_Level, bMoving
dim Font1
Const dir_up = 200 : Const dir_down = 208 : Const dir_left = 203 : Const dir_right = 205
dim map_rows, map_cols, MyMap
map_rows = 8 : map_cols = 11
' our interactive objects in the scene; max ten of each
dim s_gem(10), s_obstacle(10), s_breakable(10)
'#############################################################################
Sub Main()
if (graphics.initialize(592,388)<> True) then exit sub
dim temp
key.Initialize
Font1 = graphics.CreateFont("system", 14)
Graphics.MapInitialize
obstacle(0) = graphics.loadImage("obstacle.bmp")
breakable = graphics.loadImage("breakable.bmp")
guy = graphics.loadImage("guy.bmp")
With graphics
.SetRows guy, 4 ' number of rows in the image
.SetCols guy, 2 ' number of columns in the image
.SetTotalFrames guy, 2 ' total images for one direction of animation
.SetAnimated guy, True ' tell the application to treat this as an animated image
.SetFrameWidth guy,32 ' the width of a single frame
.SetFrameHeight guy, 32 ' the height of a single frame
.setanimateLoop guy, True
end with
Init
do while bRunning = True
if key.pressed(1) OR key.pressed(0)then bRunning = False
If bMoving = False then CheckInput ' move player if he is not already moving
graphics.clear 255
graphics.SetImage MyMap ' draw map
graphics.SetImage guy ' draw player
'
' check all of our obstacles
for temp = 1 to total_obstacles
' draw all our obstacles
graphics.SetImage obstacle(temp)
' see if it should fall
If graphics.mapGetAtt(graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32) = -1 then
'graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
'if its not moving...
If graphics.getautogoto(obstacle(temp)) = false then
' tell it how much and how fast to fall
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32, 500
' this space will soon be empty, so update the map
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
' update the map attributes to indicate the new position of the obstacle
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp))+32, 3
end if
end if
next
' check on player
' is he done making his move
If graphics.getautogoto(guy) = false then
'graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = false
' let him fall if blank space under him
If graphics.mapGetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = -1 then
MovePlayer(dir_down): bMoving = true
end if
end if
graphics.display
loop
key.terminate
graphics.terminate
end sub
'#############################################################################
Call Main
'#############################################################################
Sub Init() ' get ready to start a new round
' initialize our variables
bEnd_Level = False
InitMap(current_level)
'InitGems
'InitObstacles
'InitBreakables
end sub
'#############################################################################
Sub CheckInput()
If Key.Pressed(dir_up) then MovePlayer(dir_up)
If Key.Pressed(dir_down) then MovePlayer(dir_down)
If Key.Pressed(dir_left) then MovePlayer(dir_left)
If Key.Pressed(dir_right) then MovePlayer(dir_right)
If graphics.getautogoto(guy) = false then ' not moving
graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = False
end if
end Sub
'#############################################################################
Sub MovePlayer(direction)
If graphics.getautogoto(guy) = true then exit sub ' already moving
Dim temp
Select Case direction
Case dir_up
graphics.setcurrentFrame guy, 1
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) - 32, 500
Case dir_down
If graphics.mapgetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = 0 then exit sub
graphics.setcurrentFrame guy, 5
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) + 32, 500
Case dir_left
' see if you are at a wall
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are pushing an obstacle (big stone)
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 3 then exit sub
graphics.setcurrentFrame guy, 7
graphics.setautogoto guy, graphics.GetX(guy) - 32, graphics.GetY(guy), 500
Case dir_right
' if your next to a wall, no move
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are up against an obstacle
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 3 then
' is there a blank space next to the obstacle so it can move?
If graphics.mapgetAtt(graphics.GetX(guy) + 64, graphics.GetY(guy)) = -1 then
' determine which obstacle we are up against
for temp = 1 to total_obstacles
If Graphics.getx(obstacle(temp)) = graphics.GetX(guy) + 32 then exit for
next
' go ahead and move the obstacle
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)) + 32, graphics.GetY(obstacle(temp)), 500
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1 ' where obstacle was is now clear
else
' can't push the thing, something blocking it
exit sub
end if
end if
graphics.setcurrentFrame guy, 3
graphics.setautogoto guy, graphics.GetX(guy) + 32, graphics.GetY(guy), 500
End Select
bMoving = True
graphics.setanimateTime guy, 125
end sub
'#############################################################################
Sub InitMap(thislevel)
dim width, height
dim x, y
total_obstacles = 0 : total_breakables = 0 : total_gems = 0 : collected_gems = 0
MyMap = graphics.mapload("castle.map") ' load our precomposed map from its file
width = graphics.mapGetWidth() ' in pixels
height = graphics.mapGetHeight()' in pixels
for x = 1 to CInt(width/32) ' divide by tile width to convert to tile coordinates
for y = 1 to CInt(height/32) ' divide by tile height to convert to tile coordinates
Select Case graphics.mapGetAttC(x,y) ' get attribute via coordinates
Case 1
graphics.setXY guy, x *32, y * 32 ' set position in pixels
graphics.mapsetattc x, y, -1
Case 2
total_gems = total_gems + 1
Case 3
total_obstacles = total_obstacles + 1
obstacle(total_obstacles) = graphics.cloneImage(obstacle(0))
graphics.setXY obstacle(total_obstacles), x *32, y * 32 ' set position in pixels
Case 4
total_breakables = total_breakables + 1
End Select
next
next
end sub
'#############################################################################
dim bRunning 'if this is false the game stops running
bRunning = True
' declare our image variables
dim stone, breakable, ladder, gem, box, obstacle(9), ladder_top, guy
' our game variables
dim current_level, total_obstacles, collected_gems, move_increment, pause_time, _
total_breakables, total_gems, total_levels, dest_x, dest_y
current_level = 1
dim bEnd_Level, bMoving
dim Font1
Const dir_up = 200 : Const dir_down = 208 : Const dir_left = 203 : Const dir_right = 205
dim map_rows, map_cols, MyMap
map_rows = 8 : map_cols = 11
' our interactive objects in the scene; max ten of each
dim s_gem(10), s_obstacle(10), s_breakable(10)
'#############################################################################
Sub Main()
if (graphics.initialize(592,388)<> True) then exit sub
dim temp
key.Initialize
Font1 = graphics.CreateFont("system", 14)
Graphics.MapInitialize
obstacle(0) = graphics.loadImage("obstacle.bmp")
breakable = graphics.loadImage("breakable.bmp")
guy = graphics.loadImage("guy.bmp")
With graphics
.SetRows guy, 4 ' number of rows in the image
.SetCols guy, 2 ' number of columns in the image
.SetTotalFrames guy, 2 ' total images for one direction of animation
.SetAnimated guy, True ' tell the application to treat this as an animated image
.SetFrameWidth guy,32 ' the width of a single frame
.SetFrameHeight guy, 32 ' the height of a single frame
.setanimateLoop guy, True
end with
Init
do while bRunning = True
if key.pressed(1) OR key.pressed(0)then bRunning = False
If bMoving = False then CheckInput ' move player if he is not already moving
graphics.clear 255
graphics.SetImage MyMap ' draw map
graphics.SetImage guy ' draw player
'
' check all of our obstacles
for temp = 1 to total_obstacles
' draw all our obstacles
graphics.SetImage obstacle(temp)
' see if it should fall
If graphics.mapGetAtt(graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32) = -1 then
'graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
'if its not moving...
If graphics.getautogoto(obstacle(temp)) = false then
' tell it how much and how fast to fall
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32, 500
' this space will soon be empty, so update the map
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
' update the map attributes to indicate the new position of the obstacle
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp))+32, 3
end if
end if
next
' check on player
' is he done making his move
If graphics.getautogoto(guy) = false then
'graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = false
' let him fall if blank space under him
If graphics.mapGetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = -1 then
MovePlayer(dir_down): bMoving = true
end if
end if
graphics.display
loop
key.terminate
graphics.terminate
end sub
'#############################################################################
Call Main
'#############################################################################
Sub Init() ' get ready to start a new round
' initialize our variables
bEnd_Level = False
InitMap(current_level)
'InitGems
'InitObstacles
'InitBreakables
end sub
'#############################################################################
Sub CheckInput()
If Key.Pressed(dir_up) then MovePlayer(dir_up)
If Key.Pressed(dir_down) then MovePlayer(dir_down)
If Key.Pressed(dir_left) then MovePlayer(dir_left)
If Key.Pressed(dir_right) then MovePlayer(dir_right)
If graphics.getautogoto(guy) = false then ' not moving
graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = False
end if
end Sub
'#############################################################################
Sub MovePlayer(direction)
If graphics.getautogoto(guy) = true then exit sub ' already moving
Dim temp
Select Case direction
Case dir_up
graphics.setcurrentFrame guy, 1
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) - 32, 500
Case dir_down
If graphics.mapgetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = 0 then exit sub
graphics.setcurrentFrame guy, 5
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) + 32, 500
Case dir_left
' see if you are at a wall
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are pushing an obstacle (big stone)
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 3 then exit sub
graphics.setcurrentFrame guy, 7
graphics.setautogoto guy, graphics.GetX(guy) - 32, graphics.GetY(guy), 500
Case dir_right
' if your next to a wall, no move
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are up against an obstacle
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 3 then
' is there a blank space next to the obstacle so it can move?
If graphics.mapgetAtt(graphics.GetX(guy) + 64, graphics.GetY(guy)) = -1 then
' determine which obstacle we are up against
for temp = 1 to total_obstacles
If Graphics.getx(obstacle(temp)) = graphics.GetX(guy) + 32 then exit for
next
' go ahead and move the obstacle
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)) + 32, graphics.GetY(obstacle(temp)), 500
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1 ' where obstacle was is now clear
else
' can't push the thing, something blocking it
exit sub
end if
end if
graphics.setcurrentFrame guy, 3
graphics.setautogoto guy, graphics.GetX(guy) + 32, graphics.GetY(guy), 500
End Select
bMoving = True
graphics.setanimateTime guy, 125
end sub
'#############################################################################
Sub InitMap(thislevel)
dim width, height
dim x, y
total_obstacles = 0 : total_breakables = 0 : total_gems = 0 : collected_gems = 0
MyMap = graphics.mapload("castle.map") ' load our precomposed map from its file
width = graphics.mapGetWidth() ' in pixels
height = graphics.mapGetHeight()' in pixels
for x = 1 to CInt(width/32) ' divide by tile width to convert to tile coordinates
for y = 1 to CInt(height/32) ' divide by tile height to convert to tile coordinates
Select Case graphics.mapGetAttC(x,y) ' get attribute via coordinates
Case 1
graphics.setXY guy, x *32, y * 32 ' set position in pixels
graphics.mapsetattc x, y, -1
Case 2
total_gems = total_gems + 1
Case 3
total_obstacles = total_obstacles + 1
obstacle(total_obstacles) = graphics.cloneImage(obstacle(0))
graphics.setXY obstacle(total_obstacles), x *32, y * 32 ' set position in pixels
Case 4
total_breakables = total_breakables + 1
End Select
next
next
end sub
'#############################################################################
This is just SLIGHTLY adapted for castle.map
option explicit
dim bRunning 'if this is false the game stops running
bRunning = True
' declare our image variables
dim stone, breakable, ladder, gem, box, obstacle(9), ladder_top, guy
' our game variables
dim current_level, total_obstacles, collected_gems, move_increment, pause_time, _
total_breakables, total_gems, total_levels, dest_x, dest_y
current_level = 1
dim viewx, viewy
dim guyx, guyy
dim bEnd_Level, bMoving
dim Font1
viewx = 0
Const dir_up = 200 : Const dir_down = 208 : Const dir_left = 203 : Const dir_right = 205
dim map_rows, map_cols, MyMap
map_rows = 8 : map_cols = 11
' our interactive objects in the scene; max ten of each
dim s_gem(10), s_obstacle(10), s_breakable(10)
'#############################################################################
Sub Main()
if (graphics.initialize <> True) then exit sub
dim temp
key.Initialize
Font1 = graphics.CreateFont("system", 14)
Graphics.MapInitialize
obstacle(0) = graphics.loadImage("obstacle.bmp")
breakable = graphics.loadImage("breakable.bmp")
guy = graphics.loadImage("guy.bmp")
guyy = 300
With graphics
.SetRows guy, 4 ' number of rows in the image
.SetCols guy, 2 ' number of columns in the image
.SetTotalFrames guy, 2 ' total images for one direction of animation
.SetAnimated guy, True ' tell the application to treat this as an animated image
.SetFrameWidth guy,32 ' the width of a single frame
.SetFrameHeight guy, 32 ' the height of a single frame
.setanimateLoop guy, True
.setxy guy, guyx, guyy
end with
Init
do while bRunning = True
if key.pressed(1) OR key.pressed(0)then bRunning = False
If bMoving = False then CheckInput ' move player if he is not already moving
graphics.clear 255
graphics.SetImage MyMap ' draw map
graphics.SetImage guy ' draw player
'
' check all of our obstacles
for temp = 1 to total_obstacles
' draw all our obstacles
graphics.SetImage obstacle(temp)
' see if it should fall
If graphics.mapGetAtt(graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32) = -1 then
'graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
'if its not moving...
If graphics.getautogoto(obstacle(temp)) = false then
' tell it how much and how fast to fall
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)) + 32, 500
' this space will soon be empty, so update the map
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1
' update the map attributes to indicate the new position of the obstacle
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp))+32, 3
end if
end if
next
' check on player
' is he done making his move
If graphics.getautogoto(guy) = false then
'graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = false
' let him fall if blank space under him
If graphics.mapGetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = -1 then
MovePlayer(dir_down): bMoving = true
end if
end if
' if viewx + screenwidth > mapwidth then viewx = mapwidth - screenwidth
graphics.display
loop
key.terminate
graphics.terminate
end sub
'#############################################################################
Call Main
'#############################################################################
Sub Init() ' get ready to start a new round
' initialize our variables
bEnd_Level = False
InitMap(current_level)
'InitGems
'InitObstacles
'InitBreakables
end sub
'#############################################################################
Sub CheckInput()
If Key.Pressed(dir_up) then MovePlayer(dir_up)
If Key.Pressed(dir_down) then MovePlayer(dir_down)
If Key.Pressed(dir_left) then MovePlayer(dir_left)
If Key.Pressed(dir_right) then
MovePlayer(dir_right)
guyx = graphics.GetX(guy)
guyy = graphics.Gety(guy)
' if guyx > 300 then
viewx = viewx + 1
graphics.MapViewX viewx
graphics.mapupdate
' end if
end if
If graphics.getautogoto(guy) = false then ' not moving
graphics.setanimateTime guy, 0 'stop autoanimation
bMoving = False
end if
end Sub
'#############################################################################
Sub MovePlayer(direction)
If graphics.getautogoto(guy) = true then exit sub ' already moving
Dim temp
Select Case direction
Case dir_up
graphics.setcurrentFrame guy, 1
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) - 32, 500
Case dir_down
If graphics.mapgetAtt(graphics.GetX(guy), graphics.GetY(guy) + 32) = 0 then exit sub
graphics.setcurrentFrame guy, 5
graphics.setautogoto guy, graphics.GetX(guy), graphics.GetY(guy) + 32, 500
Case dir_left
' see if you are at a wall
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are pushing an obstacle (big stone)
If graphics.mapgetAtt(graphics.GetX(guy) - 32, graphics.GetY(guy)) = 3 then exit sub
graphics.setcurrentFrame guy, 7
graphics.setautogoto guy, graphics.GetX(guy) - 32, graphics.GetY(guy), 500
Case dir_right
' if your next to a wall, no move
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 0 then exit sub
' see if you are up against an obstacle
If graphics.mapgetAtt(graphics.GetX(guy) + 32, graphics.GetY(guy)) = 3 then
' is there a blank space next to the obstacle so it can move?
If graphics.mapgetAtt(graphics.GetX(guy) + 64, graphics.GetY(guy)) = -1 then
' determine which obstacle we are up against
for temp = 1 to total_obstacles
If Graphics.getx(obstacle(temp)) = graphics.GetX(guy) + 32 then exit for
next
' go ahead and move the obstacle
graphics.setautogoto obstacle(temp), graphics.GetX(obstacle(temp)) + 32, graphics.GetY(obstacle(temp)), 500
graphics.mapsetatt graphics.GetX(obstacle(temp)), graphics.GetY(obstacle(temp)), -1 ' where obstacle was is now clear
else
' can't push the thing, something blocking it
exit sub
end if
end if
graphics.setcurrentFrame guy, 3
graphics.setautogoto guy, graphics.GetX(guy) + 32, graphics.GetY(guy), 500
End Select
bMoving = True
graphics.setanimateTime guy, 125
end sub
'#############################################################################
Sub InitMap(thislevel)
dim width, height
dim x, y
total_obstacles = 0 : total_breakables = 0 : total_gems = 0 : collected_gems = 0
MyMap = graphics.mapload("sidescroll.map") ' load our precomposed map from its file
width = graphics.mapGetWidth() ' in pixels
height = graphics.mapGetHeight()' in pixels
for x = 1 to CInt(width/32) ' divide by tile width to convert to tile coordinates
for y = 1 to CInt(height/32) ' divide by tile height to convert to tile coordinates
Select Case graphics.mapGetAttC(x,y) ' get attribute via coordinates
Case 1
graphics.setXY guy, x *32, y * 32 ' set position in pixels
graphics.mapsetattc x, y, -1
Case 2
total_gems = total_gems + 1
Case 3
total_obstacles = total_obstacles + 1
obstacle(total_obstacles) = graphics.cloneImage(obstacle(0))
graphics.setXY obstacle(total_obstacles), x *32, y * 32 ' set position in pixels
Case 4
total_breakables = total_breakables + 1
End Select
next
next
end sub
'#############################################################################
The 2nd one is for sidescroll.map You need to edit the atributes to make the ground unwalkable....