% What is this? My attempt at our (Dejan and I) mapping system...it stinks, but it's a start!
% setting the screen
setscreen ("graphics:640;480,nobuttonbar,nocursor,position:top;center,offscreenonly")
% yes these variables are global...get over it!!
% half of these variables im not even using yet
% static variables (variables that will change depending on what track is chosen)
var TrackWidth : int := 10 % number of screens wide a track is
var TrackHeight : int := 5 % number of screens high a track is
var screenHieght : int := 480 % hieght of one screen
var screenWidth : int := 640 % width of one screen
var screenDirectory : string := "screens1/"
var NumberofScreens : int := 10 % number of screen files for that particular track
% other variables
var TrackData : int % text File with the data for that particular track
var ScreenImages : array 1 .. NumberofScreens of int
var MapX : int := 1 % x co-ordinate of map
var MapY : int := 1 % y co-ordinate of map
var chars : array char of boolean % for input.KeyDown
var MoveSpeed : int := 5 % amount of pixels map will move each time
var car := Pic.FileNew ("bmw-325.bmp")
Pic.SetTransparentColor (car, 13)
car := Pic.Scale (car, Pic.Width (car) div 1.5, Pic.Height (car) div 1.5)
var mainMap : int
var count := 1
%%%%%%%%%procedures%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% procedure readData % read data about specific track
procedure LoadScreens % for loading maps
put "Loading Maps..."
for i : 1 .. NumberofScreens
ScreenImages (i) := Pic.FileNew (screenDirectory + intstr (i) + ".bmp") %Load every image, in order, from the file folder that holds the screens
end for
end LoadScreens
procedure DrawCar % drawing the car
Pic.Draw (car, 320 - (Pic.Width (car) div 2), 240 - (Pic.Height (car) div 2), picMerge) % Draws car at center
end DrawCar
procedure DrawMap % long and inefficient mapping system...currently under construction!
cls
if MapX > Pic.Width (mainMap) or MapY > Pic.Height (mainMap) then
mainMap := ScreenImages (count)
end if
if MapX > 1 then % drawing new maps...needs fixing!!!
if ScreenImages (count) = mainMap then % basically, when main map moves right, it draws another map to the left of it
count -= 1
end if
Pic.Draw (ScreenImages (count), MapX - Pic.Width (mainMap), MapY, picCopy)
end if
if MapX < 1 then % when main map moves right, draws another map to the right of main map
if ScreenImages (count) = mainMap then
count += 1
end if
Pic.Draw (ScreenImages (count), MapX + Pic.Width (mainMap), MapY, picCopy)
end if
if MapY > 1 then % when main map moves up, draws another map underneath
if ScreenImages (count) = mainMap then
count += 1
end if
Pic.Draw (ScreenImages (count), MapX, MapY - Pic.Height (mainMap), picCopy)
end if
if MapY < 1 then % when the main map moves down, dras another one above it
if ScreenImages (count) = mainMap then
count -= 1
end if
Pic.Draw (ScreenImages (count), MapX, MapY + Pic.Height (mainMap), picCopy)
end if
Pic.Draw (mainMap, MapX, MapY, picCopy)
if MapX > 1 and MapY > 1 then % when map moves up AND left, draws a map at lower left corner
if ScreenImages (count) = mainMap then
count += 1
end if
Pic.Draw (ScreenImages (count), MapX - Pic.Width (mainMap), MapY - Pic.Height (mainMap), picCopy)
end if
if MapX < 1 and MapY < 1 then % when map moves down and right, draws map at upper right corner
if ScreenImages (count) = mainMap then
count -= 1
end if
Pic.Draw (ScreenImages (count), MapX + Pic.Width (mainMap), MapY + Pic.Height (mainMap), picCopy)
end if
if MapX < 1 and MapY > 1 then % when map moves up and right, draws map at lower right corner
if ScreenImages(count) = mainMap then
count += 1
end if
Pic.Draw (ScreenImages (count), MapX + Pic.Width (mainMap), MapY - Pic.Height(mainMap), picCopy)
end if
if MapX > 1 and MapY < 1 then % when map moves down and left, draws a map at upper left corner
if ScreenImages(count) = mainMap then
count -= 1
end if
Pic.Draw (ScreenImages (count), MapX - Pic.Width (mainMap), MapY + Pic.Height(mainMap), picCopy)
end if
end DrawMap
procedure Move % moving the map!
if chars (KEY_UP_ARROW) then % depending on what you press, the co-ordinates of the map will change
MapY -= MoveSpeed
end if
if chars (KEY_DOWN_ARROW) then
MapY += MoveSpeed
end if
if chars (KEY_LEFT_ARROW) then
MapX += MoveSpeed
end if
if chars (KEY_RIGHT_ARROW) then
MapX -= MoveSpeed
end if
% self explanitory
end Move
%%%%%%%%%% main program %%%%%%%%%%%%
LoadScreens
mainMap := ScreenImages (5)
loop
View.Update
DrawMap % loads map
DrawCar % draws car in middle, over the map
Input.KeyDown (chars)
Move % determines new co-ordinates for the next loop
end loop
|