Skip to content
Extraits de code Groupes Projets
Valider bab524ca rédigé par Vany Ingenzi's avatar Vany Ingenzi
Parcourir les fichiers

Pushed raissa modification

parent 74ad6c6c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -43,7 +43,7 @@ in
Toolbar=lr(glue:we tbbutton(text:"Quit" glue:w action:toplevel#close))
Desc=grid(handle:Grid height:500 width:500)
DescScore=grid(handle:GridScore height:100 width:500)
Window={QTk.build td(Toolbar Desc DescScore)}
Window={QTk.build td(title:"Captain Sonoz" Toolbar Desc DescScore)}
{Window show}
......
Fichier ajouté
functor
import
QTk at 'x-oz://system/wp/QTk.ozf'
Input
Player020Human
export
portWindow:StartWindow
define
StartWindow
TreatStream
RemoveItem
RemovePath
RemovePlayer
Map = Input.map
NRow = Input.nRow
NColumn = Input.nColumn
DrawSubmarine
MoveSubmarine
DrawMine
RemoveMine
DrawPath
BuildWindow
Label
Squares
DrawMap
StateModification
UpdateLife
in
%%%%% Build the initial window and set it up (call only once)
fun{BuildWindow}
Grid GridScore Toolbar Desc DescScore Window
in
Toolbar=lr(glue:we
tbbutton(text:"Quit" glue:w action:toplevel#close))
Desc=grid(handle:Grid height:500 width:500)
DescScore=grid(handle:GridScore height:100 width:500)
Window={QTk.build td(title:"Human Player Panel" Toolbar Desc DescScore)}
{Window show}
% configure rows and set headers
{Grid rowconfigure(1 minsize:50 weight:0 pad:2)}
for N in 1..NRow do
{Grid rowconfigure(N+1 minsize:50 weight:0 pad:2)}
{Grid configure({Label N} row:N+1 column:1 sticky:wesn)}
end
% configure columns and set headers
{Grid columnconfigure(1 minsize:50 weight:0 pad:2)}
for N in 1..NColumn do
{Grid columnconfigure(N+1 minsize:50 weight:0 pad:2)}
{Grid configure({Label N} row:1 column:N+1 sticky:wesn)}
end
% configure scoreboard
{GridScore rowconfigure(1 minsize:50 weight:0 pad:2)}
for N in 1..(Input.nbPlayer) do
{GridScore columnconfigure(N minsize:50 weight:0 pad:2)}
end
{DrawMap Grid}
handle(grid:Grid score:GridScore)
end
%%%%% Squares of water and island
Squares = square(0:label(text:"" width:1 height:1 bg:c(102 102 255))
1:label(text:"" borderwidth:5 relief:raised width:1 height:1 bg:c(153 76 0))
)
%%%%% Labels for rows and columns
fun{Label V}
label(text:V borderwidth:5 relief:raised bg:c(255 51 51) ipadx:5 ipady:3)
end
%%%%% Function to draw the map
proc{DrawMap Grid}
proc{DrawColumn Column M N}
case Column
of nil then skip
[] T|End then
{Grid configure(Squares.T row:M+1 column:N+1 sticky:wesn)}
{DrawColumn End M N+1}
end
end
proc{DrawRow Row M}
case Row
of nil then skip
[] T|End then
{DrawColumn T M 1}
{DrawRow End M+1}
end
end
in
{DrawRow Map 1}
end
%%%%% Init the submarine
fun{DrawSubmarine Grid ID Position}
Handle HandlePath HandleScore X Y Id Color LabelSub LabelScore
in
pt(x:X y:Y) = Position
id(id:Id color:Color name:_) = ID
LabelSub = label(text:"S" handle:Handle borderwidth:2 relief:raised bg:Color ipadx:2 ipady:2)
LabelScore = label(text:Input.maxDamage borderwidth:2 handle:HandleScore relief:solid bg:Color ipadx:2 ipady:2)
HandlePath = {DrawPath Grid Color X Y}
{Grid.grid configure(LabelSub row:X+1 column:Y+1 sticky:wesn)}
{Grid.score configure(LabelScore row:1 column:Id sticky:wesn)}
{HandlePath 'raise'()}
{Handle 'raise'()}
guiPlayer(id:ID score:HandleScore submarine:Handle mines:nil path:HandlePath|nil)
end
fun{MoveSubmarine Position}
fun{$ Grid State}
ID HandleScore Handle Mine Path NewPath X Y
in
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:Path) = State
pt(x:X y:Y) = Position
NewPath = {DrawPath Grid ID.color X Y}
{Grid.grid remove(Handle)}
{Grid.grid configure(Handle row:X+1 column:Y+1 sticky:wesn)}
{NewPath 'raise'()}
{Handle 'raise'()}
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:NewPath|Path)
end
end
fun{DrawMine Position}
fun{$ Grid State}
ID HandleScore Handle Mine Path LabelMine HandleMine X Y
in
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:Path) = State
pt(x:X y:Y) = Position
LabelMine = label(text:"M" handle:HandleMine borderwidth:5 relief:raised bg:ID.color ipadx:2 ipady:2)
{Grid.grid configure(LabelMine row:X+1 column:Y+1)}
{HandleMine 'raise'()}
{Handle 'raise'()}
guiPlayer(id:ID score:HandleScore submarine:Handle mines:mine(HandleMine Position)|Mine path:Path)
end
end
local
fun{RmMine Grid Position List}
case List
of nil then nil
[] H|T then
if (H.2 == Position) then %ERREUR CORRIGE
{RemoveItem Grid H.1}
T
else
H|{RmMine Grid Position T}
end
end
end
in
fun{RemoveMine Position}
fun{$ Grid State}
ID HandleScore Handle Mine Path NewMine
in
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:Path) = State
NewMine = {RmMine Grid Position Mine}
guiPlayer(id:ID score:HandleScore submarine:Handle mines:NewMine path:Path)
end
end
end
fun{DrawPath Grid Color X Y}
Handle LabelPath
in
LabelPath = label(text:"" handle:Handle bg:Color)
{Grid.grid configure(LabelPath row:X+1 column:Y+1)}
Handle
end
proc{RemoveItem Grid Handle}
{Grid.grid forget(Handle)}
end
fun{RemovePath Grid State}
ID HandleScore Handle Mine Path
in
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:Path) = State
for H in Path.2 do
{RemoveItem Grid H}
end
guiPlayer(id:ID score:HandleScore submarine:Handle mines:Mine path:Path.1|nil)
end
fun{UpdateLife Life}
fun{$ Grid State}
HandleScore
in
guiPlayer(id:_ score:HandleScore submarine:_ mines:_ path:_) = State
{HandleScore set(Life)}
State
end
end
fun{StateModification Grid WantedID State Fun}
case State
of nil then nil
[] guiPlayer(id:ID score:_ submarine:_ mines:_ path:_)|Next then
if (ID == WantedID) then
{Fun Grid State.1}|Next
else
State.1|{StateModification Grid WantedID Next Fun}
end
end
end
fun{RemovePlayer Grid WantedID State}
case State
of nil then nil
[] guiPlayer(id:ID score:HandleScore submarine:Handle mines:M path:P)|Next then
if (ID == WantedID) then
{HandleScore set(0)} %ERREUR CORRIGE
for H in P do
{RemoveItem Grid H}
end
for H in M do
{RemoveItem Grid H.1}
end
{RemoveItem Grid Handle}
Next
else
State.1|{RemovePlayer Grid WantedID Next}
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fun{StartWindow}
Stream
Port
in
{NewPort Stream Port}
thread
{TreatStream Stream nil nil}
end
Port
end
proc{TreatStream Stream Grid State}
case Stream
of nil|T then skip
[] buildWindow|T then NewGrid in
NewGrid = {BuildWindow}
{TreatStream T NewGrid State}
[] initPlayer(ID Position)|T then NewState in
NewState = {DrawSubmarine Grid ID Position}
{TreatStream T Grid NewState|State}
[] movePlayer(ID Position)|T then
{TreatStream T Grid {StateModification Grid ID State {MoveSubmarine Position}}}
[] lifeUpdate(ID Life)|T then
{TreatStream T Grid {StateModification Grid ID State {UpdateLife Life}}}
[] putMine(ID Position)|T then
{TreatStream T Grid {StateModification Grid ID State {DrawMine Position}}}
[] removeMine(ID Position)|T then
{TreatStream T Grid {StateModification Grid ID State {RemoveMine Position}}}
[] surface(ID)|T then
{TreatStream T Grid {StateModification Grid ID State RemovePath}}
[] removePlayer(ID)|T then
{TreatStream T Grid {RemovePlayer Grid ID State}}
[] explosion(ID Position)|T then
{TreatStream T Grid State}
[] drone(ID Drone)|T then
{TreatStream T Grid State}
[] sonar(ID)|T then
{TreatStream T Grid State}
[] _|T then
{TreatStream T Grid State}
end
end
end
Fichier ajouté
......@@ -113,11 +113,11 @@ in
%%%% Style of game %%%%
IsTurnByTurn = true
IsTurnByTurn = false
%%%% Players description %%%%
NbPlayers = 7
NbPlayers = 8
Players = [
player003bomberman
player003memory
......@@ -126,7 +126,7 @@ in
player020random
player020hiderandseeker
player038cartographer
%player069rocketman
player020human
]
Colors = [
c(245 88 203)
......@@ -135,8 +135,8 @@ in
green
red
c(178 102 255)
%c(0 204 204)
c(204 204 0)
c(133 133 99)
]
%%%% Surface time/turns %%%%
......
Fichier ajouté
......@@ -292,7 +292,7 @@ define
[] _#surface then
{Broadcast PlayersList saySurface(ID)}
{Send GUI_PORT surface(ID)}
{Delay Input.turnSurface * 1000}
{Delay Input.turnSurface * 100}
% Go to 1.
{Simultaneous Player PlayersList}
else
......@@ -310,50 +310,62 @@ define
ID KindItem
in
{Send Player.port chargeItem(ID KindItem)}
case KindItem of null then
case ID#KindItem
of null#_ then
skip
[] _#null then
{Delay Input.thinkMax * 100}
{Simultaneous91011 Player PlayersList}
else
{Simultaneous910 Player PlayersList}
[] _#ChargedItem then
{Broadcast PlayersList sayCharge(ID KindItem)}
{Delay Input.thinkMax * 100}
{Simultaneous91011 Player PlayersList}
{Simultaneous910 Player PlayersList}
end
end
% 9. Submarine fire and/or explode an item
% 10. Think
proc{Simultaneous91011 Player PlayersList}
proc{Simultaneous910 Player PlayersList}
ID KindFire
in
{Send Player.port fireItem(ID KindFire)}
case KindFire of null then
{Delay Input.thinkMax * 100}
{Simultaneous Player PlayersList}
{Simultaneous1112 Player PlayersList}
[] mine(Position) then
Id Mine
in
{Send GUI_PORT putMine(ID Position)}
{Broadcast PlayersList sayMinePlaced(ID)}
{Send Player.port fireMine(Id Mine)}
case Mine of null then
{Delay Input.thinkMax * 100}
{Simultaneous Player PlayersList}
[] mine(PosMineExploded) then
{Delay Input.thinkMax * 100}
{Send GUI_PORT removeMine(Id PosMineExploded)}
{ManageMineExplosion Id PlayersList Position}
{Simultaneous Player PlayersList}
end
{Delay Input.thinkMax * 100}
{Simultaneous1112 Player PlayersList}
[] missile(Position) then
{ManageMissileExplosion ID PlayersList Position}
{Simultaneous Player PlayersList}
{Delay Input.thinkMax * 100}
{Simultaneous1112 Player PlayersList}
[] drone(U V) then
{Send GUI_PORT drone(ID KindFire)}
{ManagingDroneFiring PlayersList Player KindFire}
{Simultaneous Player PlayersList}
{Delay Input.thinkMax * 100}
{Simultaneous1112 Player PlayersList}
[] sonar then
{Send GUI_PORT sonar(ID)}
{ManagingSonarFiring PlayersList Player}
{Delay Input.thinkMax * 100}
{Simultaneous1112 Player PlayersList}
end
end
proc{Simultaneous1112 Player PlayersList}
Id Mine
in
{Send Player.port fireMine(Id Mine)}
case Mine
of null then
{Delay Input.thinkMax * 100}
{Simultaneous Player PlayersList}
[] pt(x:_ y:_) then
{Send GUI_PORT explosion(Id Mine)}
{ManageMineExplosion Id PlayersList Mine}
{Send GUI_PORT removeMine(Id Mine)}
{Simultaneous Player PlayersList}
end
end
......
Fichier ajouté
Fichier ajouté
Ce diff est replié.
Fichier ajouté
Fichier ajouté
Fichier supprimé
......@@ -6,6 +6,7 @@ import
Player014WellerMine
Player020HiderAndSeeker
Player020Random
Player020Human
Player038Cartographer
Player069Rocketman
export
......@@ -31,6 +32,8 @@ in
{Player038Cartographer.portPlayer Color ID}
[] player069rocketman then
{Player069Rocketman.portPlayer Color ID}
[] player020human then
{Player020Human.portPlayer Color ID}
end
end
end
\ No newline at end of file
Fichier ajouté
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter