| var manID, manID2, background, background2, ghostID, newmanID, background3 : int
var manx, many : int
 var stepsize : int := 10
 var key : string (1)
 var ghostX, ghostY : int
 
 procedure loadpictures
 manID := Pic.FileNew ("Pictures\\man.bmp")
 manID := Pic.Scale (manID, 35, 35)
 manID2 := Pic.FileNew ("Pictures\\man2.bmp")
 manID2 := Pic.Scale (manID, 35, 35)
 ghostID := Pic.FileNew ("Pictures\\ghost.bmp")
 ghostID := Pic.Scale (ghostID, 30, 25)
 background := Pic.FileNew ("Pictures\\desktop.bmp")
 background := Pic.Scale (background, maxx, maxy)
 background2 := Pic.FileNew ("Pictures\\desktop.bmp")
 background2 := Pic.Scale (background2, maxx, maxy)
 background3 := Pic.FileNew ("Pictures\\desktop.bmp")
 background3 := Pic.Scale (background3, maxx, maxy)
 Pic.Draw (background, 0, 0, picCopy)
 end loadpictures
 
 procedure newgame
 manx := maxx div 2 - Pic.Width (manID) div 2
 many := maxy div 2 - Pic.Width (manID) div 2
 ghostX := 100
 ghostY := 100
 Pic.Draw (background, 0, 0, picCopy)
 background2 := Pic.New (manx, many, manx + Pic.Width (manID), many + Pic.Height (manID))
 background3 := Pic.New (ghostX, ghostY, ghostX + Pic.Width (ghostID), ghostY + Pic.Height (ghostID))
 Pic.Draw (manID, manx, many, picMerge)
 Pic.Draw (ghostID, ghostX, ghostY, picMerge)
 end newgame
 
 
 procedure collisioncheck
 
 % if ghostX > manx and manx < ghostX and many > ghostY and ghostY < many then
 
 if (manx <= ghostX + Pic.Width (ghostID)) and
 (many >= ghostY - Pic.Height (manID)) and
 (many <= ghostY + Pic.Height (ghostID)) and
 (manx >= ghostX - Pic.Width (manID)) and
 (manx <= ghostX + Pic.Width (manID)) then
 put "collision" %this is here to let me know there is collision for now
 end if
 
 end collisioncheck
 
 
 procedure movement
 
 loop
 if hasch = true then
 getch (key)
 
 %left key
 if ord (key) = 203 then
 View.Set ("offscreenonly")
 if manx - stepsize < 0 then
 manx := 0
 else
 manx := manx - stepsize
 end if
 Pic.Free (background2)
 Pic.Draw (background, 0, 0, picCopy)
 newmanID := Pic.Mirror (manID)
 background2 := Pic.New (manx, many, manx + Pic.Width (manID), many + Pic.Height (manID))
 Pic.Draw (newmanID, manx, many, picMerge)
 View.Update
 
 %right key
 elsif ord (key) = 205 then
 View.Set ("offscreenonly")
 if manx + Pic.Width (manID) + stepsize > maxx then
 manx := maxx - Pic.Width (manID)
 else
 manx := manx + stepsize
 end if
 Pic.Free (background2)
 background2 := Pic.New (manx, many, manx + Pic.Width (manID), many + Pic.Height (manID))
 Pic.Draw (background, 0, 0, picCopy)
 Pic.Draw (manID, manx, many, picMerge)
 View.Update
 
 %up key
 elsif ord (key) = 200 then
 View.Set ("offscreenonly")
 if many + Pic.Height (manID) + stepsize > maxy then
 many := maxy - Pic.Height (manID)
 else
 many := many + stepsize
 end if
 Pic.Free (background2)
 background2 := Pic.New (manx, many, manx + Pic.Width (manID), many + Pic.Height (manID))
 Pic.Draw (background, 0, 0, picCopy)
 newmanID := Pic.Rotate (manID, 90, -1, -1)
 Pic.Draw (newmanID, manx, many, picMerge)
 View.Update
 
 %down key
 elsif ord (key) = 208 then
 View.Set ("offscreenonly")
 if many - stepsize < 0 then
 many := 0
 else
 many := many - stepsize
 end if
 Pic.Free (background2)
 background2 := Pic.New (manx, many, manx + Pic.Width (manID), many + Pic.Height (manID))
 Pic.Draw (background, 0, 0, picCopy)
 newmanID := Pic.Rotate (manID, 270, -1, -1)
 Pic.Draw (newmanID, manx, many, picMerge)
 View.Update
 end if
 end if
 collisioncheck
 end loop
 end movement
 
 procedure ghostmove
 loop
 if manx < ghostX then
 Pic.Draw (background3, ghostX, ghostY, picMerge)
 View.Set ("offscreenonly")
 ghostX := ghostX - stepsize
 %move right
 elsif manx > ghostX then
 Pic.Draw (background3, ghostX, ghostY, picMerge)
 View.Set ("offscreenonly")
 ghostX := ghostX + stepsize
 %move up
 end if
 if many > ghostY then
 Pic.Draw (background3, ghostX, ghostY, picMerge)
 View.Set ("offscreenonly")
 ghostY := ghostY + stepsize
 %move down
 elsif many < ghostY then
 Pic.Draw (background3, ghostX, ghostY, picMerge)
 View.Set ("offscreenonly")
 ghostY := ghostY - stepsize
 end if
 delay (150)
 background3 := Pic.New (ghostX, ghostY, ghostX + Pic.Width (ghostID), ghostY + Pic.Height (ghostID))
 Pic.Draw (ghostID, ghostX, ghostY, picMerge)
 View.Update
 end loop
 collisioncheck
 end ghostmove
 
 %MAIN PROGRAM%
 
 loadpictures
 newgame
 process Move
 ghostmove
 end Move
 fork Move
 movement
 |