• No results found

Resultat och framtida förbättringar

In document Nätverksspel i Macromedia Director (Page 32-69)

Arbetet har gett mig en bra insyn i hur Director fungerar som utvecklingsmiljö, vad som är Directors styrkor och nackdelar. Om man tittar på de mål som sattes upp för arbetet tycker jag att jag lyckats bra att skaffa mig en bild av några av de metoder som finns tillgängliga för att skapa nätverksapplikationer i Macromedia Director. Jag har skapat ett spel där flera spelare kan spela mot varandra över ett nätverk. Spelet blev relativt enkelt att spela och lära sig, och enligt den lilla skara testspelare jag hade var det även underhållande. Grafiken i spelet blev ändamålsenlig och tillförde den klassiska retrokänslan som eftersträvades.

Om man tittar på vilka delar som skulle kunna förbättras så är den mest kritiska punkten möjligheterna till att hitta andra spelare på Internet. Det saknas just nu en funktion i spelet för att automatiskt kunna få fram en lista på alla spel som man kan

koppla upp sig mot. En lösning på detta vore att skapa en huvudserver dit alla som startar ett parti rapporterar att de startat och vilket IP-adress de har. När sedan någon letar efter ett parti att gå med i, behöver man bara fråga huvudservern vilka partier som finns tillgängliga, och få IP-adressen så att man kan koppla upp sig. Problemet med att ha en huvudserver är att den måste underhållas, och att ha en server med fast IP-adress och uppkoppling så att den alltid finns tillgänglig.

Den del av koden som ritar upp grafiken borde gå att optimera så att den inte ritar sådant som inte syns i bild. För tillfället går koden igenom alla rutor även om de inte är i bild. Spelet lider inte av det, då det inte finns några mjuka animeringar. Men om samma sätt att rita grafiken skulle användas i snabbare spel med fler animeringar kanske prestandan skulle sänkas.

På grund av tidsbegränsning blev testningen mycket begränsad och jag antar att det finns buggar kvar att upptäcka. Innan spelet kan läggas ut på Internet så att alla som vill kan spela, måste mer omfattande speltestningar genomföras så att ev. buggar hittas och kan åtgärdas.

Jag känner mig nöjd med arbetet och känner att mina kunskaper inom

programmering utvecklats mycket under arbetet. Något som förvånat mig under arbetet är att när man tittar på programkod man skrivit två veckor tidigare kan man ofta se att det går att göra på ett annat smidigare sätt. Förhoppningsvis är det ett litet bevis på att man lärt sig saker under arbetets gång.

7 Referenser

Macromedias officiella Internet site

http://www.macromedia.com Flash http://www.macromedia.com/software/flash/flashpro/ Director http://www.macromedia.com/software/director/ Java http://java.sun.com/

RoboRally, Robot Racing to the Extreme!

http://www.wizards.com/default.asp?x=ah/prod/roborally

2005-06-16

Nebulae MultiUser Server

http://xtras.tabuleiro.com/products/nebulae/index.tdb

2005-06-20

Using the Shockwave Multiuser Server and Xtra

http://download.macromedia.com/pub/director/documentation/mu_server_30.zip

2005-06-20

Flash Media Server

http://www.macromedia.com/software/flashmediaserver/

2005-06-20

Flash Communication Server reviewed

http://www.flashmagazine.com/702.htm

2005-06-20

A Little Something Xtra

http://mxdj.sys-con.com/read/43535.htm

2005-06-20

Lingo Object Oriented Programming Environment

http://www.furrypants.com/loope/

2005-08-29

Isometric Game - Part 1

http://www.lingoworkshop.com/Articles/Isometric_Game_1.php

2005-08-27

Isometric Game - Part 2

http://www.lingoworkshop.com/Articles/Isometric_Game_2.php

Imaging Lingo Basics

http://www.macromedia.com/devnet/director/articles/imaging_lingo.html

2005-08-27

Macromedia Director MX 2004, The deposed King of Interactive Authoring Applications returns from the wilderness

http://www.creativemac.com/2004/03_mar/reviews/mlr6bbjn.htm

2005-12-02

Rollings, Andrew, Adams, Ernest , Andrew Rollings and Ernest Adams on Game Design. 2000. ISBN 1592730019

Gary Rosenzweig, Special edition, Using Macormedia Director 8. 2000.

8 Bilagor

Bilaga 1 initServer Bilaga 2 initPeerConn Bilaga 3 changeServer Bilaga 4 pinga Bilaga 5 loadMap Bilaga 6 rotateMap Bilaga 7 gameEngine Bilaga 8 resolveMove Bilaga 9 GFXdraw

Bilaga 1 initServer

on initServer pingListSend = [0] pingListRecive = [0] IsServer = true started = false

gConnection = new (xtra "Multiuser") if objectP(gConnection) then

gConnection.setNetMessageHandler(#Sgameinfo, 0, "Gameinfo" ) gConnection.setNetMessageHandler(#Sping, 0, "Ping" )

gConnection.setNetMessageHandler(#Schat, 0, "chat" ) gConnection.setNetMessageHandler(#SInfor, 0, "Infor" ) gConnection.setNetMessageHandler(#SDissC, 0, "DissC" )

gConnection.setNetMessageHandler(#Sconnecttest, 0, "connecttest" ) gConnection.setNetMessageHandler(#Connect, 0, "WaitForNetConnection") gConnection.setNetMessageHandler(#Sslask, 0)

gConnection.waitForNetConnection(nick, 1626, 4)

member("lobbychat").text = member("lobbychat").text &"Waiting for users to connect..." && return

else

alert "Couldn't create an instance of the multiuser xtra"

end if

UserIP = [gConnection.getNetAddressCookie(0, 1)] UserNick = [nick]

putnamelabels end

on Sslask

newmessage = gConnection.getNetMessage() end

on StestForError errorCode if ( errorCode <> 0 ) then

alert "ERROR-server"&&GetNetErrorString( gConnection, errorCode ) end if

end on SPing

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) if newMessage.content = "ping" then

errCode = gConnection.sendNetMessage(newMessage.senderID, "Ping", "Pong") else if newMessage.content = "pong" then

i = UserNick.getpos(newMessage.senderID) pingListRecive[i] = the ticks

end if return 1

end on Schat

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) ChatTimer = the ticks

member("lobbychat").text = member("lobbychat").text & string(newMessage.senderID) &

":" && string(newmessage.content) && RETURN return 1

end

on Sconnecttest

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) repeat with i = 1 to UserNick.count

if UserNick[i] = newMessage.content then

errCode = gConnection.sendNetMessage(newMessage.senderID, "connecttest",

"nickerror") end if end repeat if started then

errCode = gConnection.sendNetMessage(newMessage.senderID, "connecttest", "started") else if UserNick.count >= 4 then

errCode = gConnection.sendNetMessage(newMessage.senderID, "connecttest", "full") else

errCode = gConnection.sendNetMessage(newMessage.senderID, "connecttest", "OK") end if

end on Connect

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode)

end on SInfor

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) UserNick.add(newMessage.content[1]) UserIP.add(newMessage.content[2]) PingListSend.add(the ticks)

PingListRecive.add(the ticks+60*10)

member("lobbychat").text = member("lobbychat").text & UserNick.getlast() && "Has joined" && RETURN

repeat with n = 2 to UserNick.count

errCode = gConnection.sendNetMessage(UserNick[n], "Infor", [UserNick,UserIP,true]) end repeat

putnamelabels return 1

end on SDissC

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) i = UserNick.getpos(newMessage.senderID)

member("lobbychat").text = member("lobbychat").text & UserNick[i] && "Has left" && RETURN

UserIP.deleteat(i) UserNick.deleteat(i) PingListSend.deleteat(i) PingListRecive.deleteat(i) if phase <> "lobby" then

i = playernames.getpos(newmessage.senderID) playerAction[i] = "Has left"

end if

repeat with n = 2 to UserNick.count

errCode = gConnection.sendNetMessage(UserNick[n], "Update", [UserNick,UserIP,newMessage.senderID]) end repeat putnamelabels return 1 end on Sgameinfo

newMessage = gConnection.getNetMessage() StestForError(newMessage.errorCode) if newMessage.content[1] = "move" then i = playernames.getpos(newmessage.senderID) playermoves[i] = newMessage.content[2] playerAction[i] = "is Done"

else if newMessage.content[1] = "alldone" then i = playernames.getpos(newmessage.senderID) playerdone[i] = "alldone"

end if end

on putnamelabels

member("lobby-player1-label").text = ""

member("lobby-player2-label").text = ""

member("lobby-player3-label").text = ""

member("lobby-player4-label").text = ""

if UserNick.count >= 1 then member("lobby-player1-label").text = UserNick[1] if UserNick.count >= 2 then member("lobby-player2-label").text = UserNick[2] if UserNick.count >= 3 then member("lobby-player3-label").text = UserNick[3] if UserNick.count >= 4 then member("lobby-player4-label").text = UserNick[4] end

Bilaga 2 initPeerConn

on initPeerConn pingListSend = [0] pingListRecive = [0] UserIP = [0] UserNick = [0] IsServer = false

gConnection = new( xtra "Multiuser" ) if objectP( gConnection ) then

gConnection.setNetMessageHandler(#Gameinfo, 0, "Gameinfo") gConnection.setNetMessageHandler(#Ping, 0, "Ping")

gConnection.setNetMessageHandler(#Chat, 0, "Chat") gConnection.setNetMessageHandler(#Infor, 0, "Infor") gConnection.setNetMessageHandler(#UpdateUsers, 0, "Update") gConnection.setNetMessageHandler(#ConnectTest, 0, "connecttest") gConnection.setNetMessageHandler(#Connected, 0, "ConnectToNetServer" ) gConnection.setNetMessageHandler(#slask, 0)

errCode = gConnection.ConnectToNetServer( "connecttest", "password", serverip, 1626, nick )

member("menu-joindialog").text = "Joining game @" && serverip connecttimer = the ticks

testForError( errCode ) else

alert "Couldn't make an instace of the multiuser xtra"

end if

end initPeerConn

on testForError errorCode if ( errorCode <> 0 ) then

member("menu-joindialog").text = "Couldn't find server"

end if

end testForError on slask

newmessage = gConnection.getNetMessage() end

on Ping

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) if newMessage.content = "ping" then

errCode = gConnection.sendNetMessage(newMessage.senderID, "Ping", "Pong") else if newMessage.content = "pong" then

pingListRecive[1] = the ticks

end if return 1

end on Chat

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) ChatTimer = the ticks

member("lobbychat").text = member("lobbychat").text & string(newMessage.senderID) &

":" && string(newmessage.content) && RETURN return 1

end on Infor

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) UserNick = newMessage.content[1] UserIP = newMessage.content[2] pingListSend[1] = the ticks

PingListRecive[1] = the ticks + 60*10

member("lobbychat").text = member("lobbychat").text & UserNick.getlast() && "Has joined the game" && RETURN

putnamelabels return 1

end

on UpdateUsers

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) UserNick = newMessage.content[1] UserIP = newMessage.content[2] if phase <> "lobby" then

i = playernames.getpos(newmessage.content[3]) playerAction[i] = "Has left"

member("lobbychat").text = member("lobbychat").text & newMessage.content[3] && "Has left the game (quit or ping)" && RETURN

putnamelabels return 1

end

on ConnectTest

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) if newMessage.content = "nickerror" then

errCode = gConnection.breakConnection("connectiontest") if objectP( gConnection ) then

gConnection = 0

end if

member("menu-joindialog").text = "Nick allready in use in this game" && RETURN &&

"choose another nick"

else if newMessage.content = "started" then

errCode = gConnection.breakConnection("connectiontest") if objectP( gConnection ) then

gConnection = 0

end if

member("menu-joindialog").text = "Game has allready started"

else if newMessage.content = "full" then

errCode = gConnection.breakConnection("connectiontest") if objectP( gConnection ) then

gConnection = 0

end if

member("menu-joindialog").text = "Game is full"

else if newmessage.content = "ok" then

errCode = gConnection.breakConnection("connectiontest")

errCode = gConnection.ConnectToNetServer( nick, "password", serverip, 1626,

"Botrace" ) end if

connecttimer = 0

end

on Connected

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode)

if newMessage.recipients[1] = "connecttest" then

errCode = gConnection.sendNetMessage(newMessage.senderID, "connecttest", nick) else

LocalAddress = gConnection.getNetAddressCookie(0, 1)

errCode = gConnection.sendNetMessage(newMessage.senderID, "Infor", [nick,LocalAddress])

if phase = "menu" then

go to "lobby" end if phase = "lobby" return 1 end if connecttimer = 0 end on Gameinfo

newMessage = gConnection.getNetMessage() testForError(newMessage.errorCode) if newMessage.content[1] = "start" then Usemap = newMessage.content[2]

phase = "started"

else if newMessage.content[1] = "move" then i = playernames.getpos(newmessage.senderID) playermoves[i] = newMessage.content[2] playerAction[i] = "is Done"

else if newMessage.content[1] = "alldone" then i = playernames.getpos(newmessage.senderID) playerdone[i] = "alldone"

end if end

on putnamelabels

member("lobby-player1-label").text = ""

member("lobby-player2-label").text = ""

member("lobby-player3-label").text = ""

member("lobby-player4-label").text = ""

if UserNick.count >= 1 then member("lobby-player1-label").text = UserNick[1] if UserNick.count >= 2 then member("lobby-player2-label").text = UserNick[2] if UserNick.count >= 3 then member("lobby-player3-label").text = UserNick[3] if UserNick.count >= 4 then member("lobby-player4-label").text = UserNick[4]

Bilaga 3 ChangeServer

On ChangeServer

If nick = UserNick[1] and UserNick.count > 1 then

member("lobbychat").text = member("lobbychat").text & "You are now the server" && RETURN

member("lobbychat").text = member("lobbychat").text & "Making new server ("&UserNick[1] &")" && RETURN

InitServer

Else if Nick = UserNick[1] and UserNick.count = 1 and connectionLost = 0 then

member("lobbychat").text = member("lobbychat").text & "Your the only one left in the game!" && RETURN

ConnectionLost = 1

Else if Nick = UserNick[1] and UserNick.count = 1 and connectionLost = 1 and reconnecttimer + 60*5 < the ticks then

go to "menu"

phase = "menu"

connectionlost = 0

else if the ticks > ReconnectTimer + 60*5 and nick <> Usernick[1] then

member("lobbychat").text = member("lobbychat").text & "Connecting to new server (" & UserNick[1] &")..." && RETURN

serverip = UserIP[1] InitPeerConn

end if end

Bilaga 4 pinga

On pinga

if IsServer then

repeat with n = 1 to Usernick.count

if the ticks > pinglistsend[n] + (60*2) and pinglistsend[n] <> 0 then pinglistsend[n] = the ticks

errCode = gConnection.sendNetMessage(UserNick[n], "Ping", "Ping") end if

if the ticks > pinglistrecive[n] + (60*5) and pinglistrecive[n] <> 0 then

member("lobbychat").text = member("lobbychat").text & UserNick[n] && "Has pinged out..." && RETURN

temp = UserNick[n]

errCode = gConnection.breakConnection(UserNick[n]) UserIP.deleteat(n)

UserNick.deleteat(n) PingListRecive.deleteat(n) PingListSend.deleteat(n) if phase <> "lobby" then i = playernames.getpos(temp) playerAction[i] = "Has left"

end if

repeat with n = 2 to UserNick.count

errCode = gConnection.sendNetMessage(UserNick[n], "Update", [UserNick,UserIP,temp]) end repeat putnamelabels end if end repeat else

if the ticks > pinglistsend[1] + (60*2) and pinglistsend[1] <> 0 then pinglistsend[1] = the ticks

errCode = gConnection.sendNetMessage(UserNick[1], "Ping", "Ping")

else if the ticks > pinglistrecive[1] + (60*5) and pinglistrecive[1] <> 0 and pinglistrecive[1] <> 1 then

member("lobbychat").text = member("lobbychat").text & "Connection to server (" & UserNick[1] &") lost..." && RETURN

errCode = gConnection.breakConnection(nick) if objectP( gConnection ) then

gConnection = 0

end if

if phase <> "lobby" then

i = playernames.getpos(UserNick[1]) playerAction[i] = "Has left"

end if

UserIP.deleteat(1) UserNick.deleteat(1) PingListRecive[1] = 1

PingListSend[1] = 0

ReconnectTimer = the ticks

connectionlost = 0

ChangeServer

member("lobby-player1-label").text = ""

member("lobby-player2-label").text = ""

member("lobby-player3-label").text = ""

member("lobby-player4-label").text = "" else if pinglistrecive[1] = 1 then

Changeserver end if

---

-- couldn't find server

---

if connecttimer <> 0 then

if connecttimer + 60*10 < the ticks and connectionlost = 0 then

member("lobbychat").text = member("lobbychat").text = "Couldn't reconnect to server"

connectionlost = 1

else if connecttimer +60*15 < the ticks then

go to "menu"

phase = "menu"

connectionlost = 0

end if end if

Bilaga 5 loadMap

on loadMap

set MaparrayN = [] map1 = getat(Usemap, 1) map2 = getat(Usemap, 2) map3 = getat(Usemap, 3) map4 = getat(Usemap, 4) repeat with n = 1 to 8

set linje = []

repeat with i = 1 to 8

set ruta = [:] mapPart = map1

case member(mapPart).line[n*3].word[i].char[1] of

"N": setaProp ruta, #tile, "-tile" "F": setaprop ruta, #tile, "-tile-flag" "R": setaprop ruta, #tile, "-tile-repair" "H": setaprop ruta, #tile, "-tile-hole" "E": setaprop ruta, #tile, "none"

end case

case member(mapPart).line[n*3].word[i].char[2..3] of

"Ss": setaProp ruta, #belt, "belt-NS-south" "Sm": setaProp ruta, #belt, "belt-NS-middle"

"Sn": setaProp ruta, #belt, "belt-NS-north"

"Ee": setaProp ruta, #belt, "belt-WE-east" "Em": setaProp ruta, #belt, "belt-WE-middle" "Ew": setaProp ruta, #belt, "belt-WE-west" "Nn": setaProp ruta, #belt, "belt-SN-north" "Nm": setaProp ruta, #belt, "belt-SN-middle" "Ns": setaProp ruta, #belt, "belt-SN-south" "Ww": setaProp ruta, #belt, "belt-EW-west" "Wm": setaProp ruta, #belt, "belt-EW-middle" "We": setaProp ruta, #belt, "belt-EW-east" "00": setaProp ruta, #belt, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[1..2] of

"N0": setaProp ruta, #wall, "-wall-north" "W0": setaprop ruta, #wall, "-wall-west" "S0": setaProp ruta, #wall, "-wall-south" "E0": setaprop ruta, #wall, "-wall-east" "00": setaprop ruta, #wall, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[3] of

"E": setaProp ruta, #prop, "laser-turret-WE" "S": setaprop ruta, #prop, "laser-turret-NS" "W": setaProp ruta, #prop, "laser-turret-EW" "N": setaprop ruta, #prop, "laser-turret-SN" "F": setaprop ruta, #prop, "flag1"

"0": setaprop ruta, #prop, "none"

end case

setaProp ruta, #shotNS, "none"

setaProp ruta, #shotWE, "none"

setaProp ruta, #bot1, "none"

setaProp ruta, #bot2, "none"

setaProp ruta, #bot3, "none"

setaProp ruta, #bot4, "none"

linje.add(ruta) end repeat

repeat with i = 1 to 8

set ruta = [:] mapPart = map2

case member(mapPart).line[n*3].word[i].char[1] of

"N": setaProp ruta, #tile, "-tile" "F": setaprop ruta, #tile, "-tile-flag" "R": setaprop ruta, #tile, "-tile-repair" "H": setaprop ruta, #tile, "-tile-hole" "E": setaprop ruta, #tile, "none"

end case

case member(mapPart).line[n*3].word[i].char[2..3] of

"Ss": setaProp ruta, #belt, "belt-NS-south" "Sm": setaProp ruta, #belt, "belt-NS-middle"

"Sn": setaProp ruta, #belt, "belt-NS-north"

"Ee": setaProp ruta, #belt, "belt-WE-east" "Em": setaProp ruta, #belt, "belt-WE-middle"

"Nn": setaProp ruta, #belt, "belt-SN-north" "Nm": setaProp ruta, #belt, "belt-SN-middle" "Ns": setaProp ruta, #belt, "belt-SN-south" "Ww": setaProp ruta, #belt, "belt-EW-west" "Wm": setaProp ruta, #belt, "belt-EW-middle" "We": setaProp ruta, #belt, "belt-EW-east" "00": setaProp ruta, #belt, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[1..2] of

"N0": setaProp ruta, #wall, "-wall-north" "W0": setaprop ruta, #wall, "-wall-west" "S0": setaProp ruta, #wall, "-wall-south" "E0": setaprop ruta, #wall, "-wall-east" "00": setaprop ruta, #wall, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[3] of

"E": setaProp ruta, #prop, "laser-turret-WE" "S": setaprop ruta, #prop, "laser-turret-NS" "W": setaProp ruta, #prop, "laser-turret-EW" "N": setaprop ruta, #prop, "laser-turret-SN" "F": setaprop ruta, #prop, "flag2"

"0": setaprop ruta, #prop, "none"

end case

setaProp ruta, #shotNS, "none"

setaProp ruta, #shotWE, "none"

setaProp ruta, #bot1, "none"

setaProp ruta, #bot2, "none"

setaProp ruta, #bot3, "none"

setaProp ruta, #bot4, "none"

linje.add(ruta) end repeat

maparrayN.add(linje) end repeat repeat with n = 1 to 8 set linje = [] repeat with i = 1 to 8 set ruta = [:] mapPart = map3

case member(mapPart).line[n*3].word[i].char[1] of

"N": setaProp ruta, #tile, "-tile" "F": setaprop ruta, #tile, "-tile-flag" "R": setaprop ruta, #tile, "-tile-repair" "H": setaprop ruta, #tile, "-tile-hole" "E": setaprop ruta, #tile, "none"

end case

case member(mapPart).line[n*3].word[i].char[2..3] of

"Ss": setaProp ruta, #belt, "belt-NS-south" "Sm": setaProp ruta, #belt, "belt-NS-middle"

"Sn": setaProp ruta, #belt, "belt-NS-north"

"Ee": setaProp ruta, #belt, "belt-WE-east" "Em": setaProp ruta, #belt, "belt-WE-middle" "Ew": setaProp ruta, #belt, "belt-WE-west" "Nn": setaProp ruta, #belt, "belt-SN-north" "Nm": setaProp ruta, #belt, "belt-SN-middle" "Ns": setaProp ruta, #belt, "belt-SN-south" "Ww": setaProp ruta, #belt, "belt-EW-west" "Wm": setaProp ruta, #belt, "belt-EW-middle" "We": setaProp ruta, #belt, "belt-EW-east" "00": setaProp ruta, #belt, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[1..2] of

"N0": setaProp ruta, #wall, "-wall-north" "W0": setaprop ruta, #wall, "-wall-west" "S0": setaProp ruta, #wall, "-wall-south" "E0": setaprop ruta, #wall, "-wall-east" "00": setaprop ruta, #wall, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[3] of

"E": setaProp ruta, #prop, "laser-turret-WE" "S": setaprop ruta, #prop, "laser-turret-NS" "W": setaProp ruta, #prop, "laser-turret-EW" "N": setaprop ruta, #prop, "laser-turret-SN" "F": setaprop ruta, #prop, "flag4"

"0": setaprop ruta, #prop, "none"

setaProp ruta, #bot1, "none"

setaProp ruta, #bot2, "none"

setaProp ruta, #bot3, "none"

setaProp ruta, #bot4, "none"

linje.add(ruta) end repeat

repeat with i = 1 to 8

set ruta = [:] mapPart = map4

case member(mapPart).line[n*3].word[i].char[1] of

"N": setaProp ruta, #tile, "-tile" "F": setaprop ruta, #tile, "-tile-flag" "R": setaprop ruta, #tile, "-tile-repair" "H": setaprop ruta, #tile, "-tile-hole" "E": setaprop ruta, #tile, "none"

end case

case member(mapPart).line[n*3].word[i].char[2..3] of

"Ss": setaProp ruta, #belt, "belt-NS-south" "Sm": setaProp ruta, #belt, "belt-NS-middle"

"Sn": setaProp ruta, #belt, "belt-NS-north"

"Ee": setaProp ruta, #belt, "belt-WE-east" "Em": setaProp ruta, #belt, "belt-WE-middle" "Ew": setaProp ruta, #belt, "belt-WE-west" "Nn": setaProp ruta, #belt, "belt-SN-north" "Nm": setaProp ruta, #belt, "belt-SN-middle" "Ns": setaProp ruta, #belt, "belt-SN-south" "Ww": setaProp ruta, #belt, "belt-EW-west" "Wm": setaProp ruta, #belt, "belt-EW-middle" "We": setaProp ruta, #belt, "belt-EW-east" "00": setaProp ruta, #belt, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[1..2] of

"N0": setaProp ruta, #wall, "-wall-north" "W0": setaprop ruta, #wall, "-wall-west" "S0": setaProp ruta, #wall, "-wall-south" "E0": setaprop ruta, #wall, "-wall-east" "00": setaprop ruta, #wall, "none"

end case

case member(mapPart).line[n*3+1].word[i].char[3] of

"E": setaProp ruta, #prop, "laser-turret-WE" "S": setaprop ruta, #prop, "laser-turret-NS" "W": setaProp ruta, #prop, "laser-turret-EW" "N": setaprop ruta, #prop, "laser-turret-SN" "F": setaprop ruta, #prop, "flag3"

"0": setaprop ruta, #prop, "none"

end case

setaProp ruta, #shotNS, "none"

setaProp ruta, #shotWE, "none"

setaProp ruta, #bot1, "none"

setaProp ruta, #bot2, "none"

setaProp ruta, #bot3, "none"

setaProp ruta, #bot4, "none"

linje.add(ruta) end repeat

maparrayN.add(linje) end repeat

initRotate end

Bilaga 6 rotateMap

on initRotate RotateMap("w") RotateMap("s") RotateMap("e") end on RotateMap dir set maparray2 = [] if dir = "w" then set MaparrayW = [] Maparray1 = MaparrayN else if dir = "s" then set maparrayS = [] Maparray1 = MaparrayW else if dir = "e" then set maparrayE = [] Maparray1 = MaparrayS end if

Repeat with n = 1 to 16

set linje = []

repeat with i = 16 down to 1

set ruta = [:]

setaProp ruta, #tile, getat(maparray1[i],n).tile case getat(maparray1[i],n).belt of

"belt-NS-south": setaProp ruta, #belt, "belt-EW-west" "belt-NS-middle": setaProp ruta, #belt, "belt-EW-middle" "belt-NS-north": setaProp ruta, #belt, "belt-EW-east"

"belt-WE-east": setaProp ruta, #belt, "belt-NS-south" "belt-WE-middle": setaProp ruta, #belt, "belt-NS-middle" "belt-WE-west": setaProp ruta, #belt, "belt-NS-north" "belt-SN-north": setaProp ruta, #belt, "belt-WE-east" "belt-SN-middle": setaProp ruta, #belt, "belt-WE-middle" "belt-SN-south": setaProp ruta, #belt, "belt-WE-west" "belt-EW-west": setaProp ruta, #belt, "belt-SN-north" "belt-EW-middle": setaProp ruta, #belt, "belt-SN-middle" "belt-EW-east": setaProp ruta, #belt, "belt-SN-south" "none": setaProp ruta, #belt, "none"

end case

case getat(maparray1[i],n).wall of

"-wall-north": setaProp ruta, #wall, "-wall-east" "-wall-west": setaprop ruta, #wall, "-wall-north" "-wall-south": setaProp ruta, #wall, "-wall-west" "-wall-east": setaprop ruta, #wall, "-wall-south" "none": setaprop ruta, #wall, "none"

end case

case getat(maparray1[i],n).prop of

"laser-turret-WE": setaProp ruta, #prop, "laser-turret-NS" "laser-turret-NS": setaprop ruta, #prop, "laser-turret-EW" "laser-turret-EW": setaProp ruta, #prop, "laser-turret-SN" "laser-turret-SN": setaprop ruta, #prop, "laser-turret-WE"

"flag1":setaprop ruta, #prop, "flag1" "flag2":setaprop ruta, #prop, "flag2" "flag3":setaprop ruta, #prop, "flag3" "flag4" :setaprop ruta, #prop, "flag4" "none": setaprop ruta, #prop, "none"

end case

setaProp ruta, #shotNS, "none"

setaProp ruta, #shotWE, "none"

setaProp ruta, #bot1, "none"

setaProp ruta, #bot2, "none"

setaProp ruta, #bot3, "none"

setaProp ruta, #bot4, "none" linje.add(ruta)

end repeat

maparray2.add(linje) end repeat

if dir = "w" then MaparrayW = Maparray2 else if dir = "s" then MaparrayS = Maparray2 else if dir = "e" then MaparrayE = Maparray2

Bilaga 7 gameEngine

On GameEngine

if phase = "lobby" then pinga

frametimer = the ticks

startsIn = 3

end if

---

--phase started

---

if phase = "Started" then pinga

if the ticks > frametimer + 10 and startsIn = 3 then

member("lobbychat").text = member("lobbychat").text & "Game starting in ...3" && RETURN

startsIn = 2

else if the ticks > frametimer + 20 and startsIn = 2 then

member("lobbychat").text = member("lobbychat").text & "Game starting in ...2" && RETURN

startsIn = 1

else if the ticks > frametimer + 30 and startsIn = 1 then

member("lobbychat").text = member("lobbychat").text & "Game starting in ...1" && RETURN

startsIn = "now"

else if the ticks > frametimer + 40 and startsIn = "now" then setcamerato(4,4)

cameracoords = [4,4] cameraDirection = "north"

loadmap builddeck

gfxtimer = the ticks

In document Nätverksspel i Macromedia Director (Page 32-69)

Related documents