Posted: Fri Feb 27, 2004 6:51 pm Post subject: starting my final project...
since i've been bored lately and havent thought of a cool program to make, i decided to start on my final project... im going to make a multiplayer capture the falg/2d shooter/tag type game.... heres what i have so far...
Posted: Fri Feb 27, 2004 11:42 pm Post subject: (No subject)
Very nice, you might wanna make it a bit bigger though, some ppl would prolly not see it that well.
zylum
Posted: Sat Feb 28, 2004 1:38 am Post subject: (No subject)
thanks for the comments... here is an updated version and a level editor....
map editor:
code:
setscreen ("graphics:593;593")
var cols, rows : int
put "how many columns?"
get cols
put "how many rows?"
get rows
cols := min (cols, 37)
rows := min (rows, 37)
cls
var clr : int
var tile : array 1 .. cols, 1 .. rows of int
for col : 1 .. cols
for row : 1 .. rows
if row = 1 or col = 1 or row = rows or col = cols then
clr := 43
tile (col, row) := 1
else
clr := 53
tile (col, row) := 0
end if
drawfillbox ((col - 1) * 16, (row - 1) * 16, (col - 1) * 16 + 15, (row - 1) * 16 + 15, clr)
end for
end for
var mx, my, md, x, y : int
loop
mousewhere (mx, my, md)
if md = 1 then
x := mx div 16
y := my div 16
if tile (x + 1, y + 1) = 1 then
tile (x + 1, y + 1) := 0
drawfillbox ((x) * 16, (y) * 16, (x) * 16 + 15, (y) * 16 + 15, 53)
else
tile (x + 1, y + 1) := 1
drawfillbox ((x) * 16, (y) * 16, (x) * 16 + 15, (y) * 16 + 15, 43)
end if
delay (200)
end if
exit when hasch
end loop
put "what is the name of the map???"
var mapName : string
get mapName
var mapFile : int
open : mapFile, mapName, put
put : mapFile, rows
put : mapFile, cols
cls
for col : 1 .. cols
for row : 1 .. rows
if row < rows then
put : mapFile, tile (col, row) ..
put : mapFile, " " ..
else
put : mapFile, tile (col, row)
end if
end for
end for
put "map saved"
updated version which works with user made maps:
code:
setscreen ("graphics:593;593")
var mapCols := 20
var mapRows := 20
var mapDensity := 2.7
var tileSize := 16
var players : int := 1
var playerSize : int := 3
var playerTurnSpeed : real := 2
var playerMaxSpeed : real := 0.5
var playerMinSpeed : real := -0.2
var playerMoveSpeed : array 1 .. players of real
var playerSpeeds : array 1 .. players, 1 .. 2 of real
var playerCoords : array 1 .. players, 1 .. 2 of real
playerCoords (1, 1) := tileSize + tileSize / 2
playerCoords (1, 2) := tileSize + tileSize / 2
var playerAng : array 1 .. players of real
for i : 1 .. players
playerAng (i) := 0
end for
var mapPic : int
var map : array 1 .. 1000, 1 .. 1000 of int
procedure createMap (size : int, density : real, clr1, clr2 : int)
var clr : real
var mapType : string
loop
locate (1, 1)
put "random or file?"
get mapType
exit when mapType = "random" or mapType = "file"
cls
end loop
cls
var cols : int := mapCols
var rows : int := mapRows
if mapType = "random" then
for col : 1 .. cols
for row : 1 .. rows
if row = 1 or col = 1 or row = rows or col = cols then
clr := clr2
elsif row = 2 or col = 2 or row = rows - 1 or col = cols - 1 then
clr := clr1
else
clr := Rand.Real * density
if clr < density - 1 then
clr := clr1
map (col, row) := 0
else
clr := clr2
map (col, row) := 1
end if
end if
if clr = clr1 then
map (col, row) := 0
else
map (col, row) := 1
end if
drawfillbox (col * size, row * size, col * size + size, row * size + size, round (clr))
end for
end for
else
var mapFile : int
var mapFileName : string
var tile : int
var rows2, cols2 : int
%load map here
put "what is the map file name?"
get mapFileName
cls
open : mapFile, mapFileName, get
get : mapFile, mapRows
get : mapFile, mapCols
for col : 1 .. mapCols
for row : 1 .. mapRows
get : mapFile, tile
if tile = 0 then
clr := clr1
map (col, row) := 0
else
clr := clr2
map (col, row) := 1
end if
drawfillbox ((col - 1) * size, (row - 1) * size, (col - 1) * size + size, (row - 1) * size + size, round (clr))
end for
end for
end if
mapPic := Pic.New (0, 0, (mapCols - 1) * size + size, (mapRows - 1) * size + size)
cls
end createMap
var move : array char of boolean
procedure getKeyStrokes (num : int)
Input.KeyDown (move)
if move (KEY_UP_ARROW) then
playerMoveSpeed (num) := playerMaxSpeed
elsif move (KEY_DOWN_ARROW) then
playerMoveSpeed (num) := playerMinSpeed
else
playerMoveSpeed (num) := 0
end if
if move (KEY_RIGHT_ARROW) then
playerAng (num) -= playerTurnSpeed
elsif move (KEY_LEFT_ARROW) then
playerAng (num) += playerTurnSpeed
end if
if playerAng (num) > 360 then
playerAng (num) := 5
elsif playerAng (num) < 0 then
playerAng (num) := 355
end if
end getKeyStrokes
procedure checkCollision (num : int)
var x, y : real
/***X AXIS***
bottom left*/
x := (playerCoords (num, 1) + tileSize + playerSpeeds (num, 1) - playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize - playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 1) := 0
end if
%top left
x := (playerCoords (num, 1) + tileSize + playerSpeeds (num, 1) - playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 1) := 0
end if
%bottom right
x := (playerCoords (num, 1) + tileSize + playerSpeeds (num, 1) + playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize - playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 1) := 0
end if
%top right
x := (playerCoords (num, 1) + tileSize + playerSpeeds (num, 1) + playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 1) := 0
end if
/*Y AXIS
bottom left*/
x := (playerCoords (num, 1) + tileSize - playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSpeeds (num, 2) - playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 2) := 0
end if
%top left
x := (playerCoords (num, 1) + tileSize - playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSpeeds (num, 2) + playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 2) := 0
end if
%bottom right
x := (playerCoords (num, 1) + tileSize + playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSpeeds (num, 2) - playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 2) := 0
end if
%top right
x := (playerCoords (num, 1) + tileSize + playerSize) div tileSize
y := (playerCoords (num, 2) + tileSize + playerSpeeds (num, 2) + playerSize) div tileSize
if map (round (x), round (y)) = 1 then
playerSpeeds (num, 2) := 0
end if
end checkCollision
Posted: Sat Feb 28, 2004 6:22 pm Post subject: (No subject)
Well done , i like the effort you have put into this , that collision detection is way off in the second version , its almost as if it thinks its a different map , but great job anywhoo
poly
Posted: Sun Feb 29, 2004 10:17 am Post subject: (No subject)
yes i agree with everybody here, its pretty good (cant wait to see the final outcome), but collision is a bit messed up on the second version you posted. I would be walking around the blue area and all of a sudden it would act like there is a wall infront of me
zylum
Posted: Sun Feb 29, 2004 10:29 pm Post subject: (No subject)
hmm... thats odd. i havnt changed the collision detection at all...
zylum
Posted: Sun Feb 29, 2004 10:41 pm Post subject: (No subject)
oops, looks like i messed up the random map generator... heres an update for those of you who are interested...