Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
killer_sokoban
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Schulcz Ferenc
killer_sokoban
Commits
a8528239
Commit
a8528239
authored
May 13, 2018
by
tildiko97
Browse files
Options
Downloads
Patches
Plain Diff
View, Main osztályokban a JavaDoc megírása
parent
146a49c7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/killer_sokoban/Main.java
+64
-0
64 additions, 0 deletions
src/killer_sokoban/Main.java
src/killer_sokoban/View.java
+51
-0
51 additions, 0 deletions
src/killer_sokoban/View.java
with
115 additions
and
0 deletions
src/killer_sokoban/Main.java
+
64
−
0
View file @
a8528239
...
@@ -122,6 +122,9 @@ public class Main extends Application {
...
@@ -122,6 +122,9 @@ public class Main extends Application {
private
static
View
view
=
new
View
();
private
static
View
view
=
new
View
();
/**
* Játék kezdetéhez szükséges előkészüleletek
*/
@Override
@Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
// Ablak felépítése
// Ablak felépítése
...
@@ -197,6 +200,12 @@ public class Main extends Application {
...
@@ -197,6 +200,12 @@ public class Main extends Application {
}
}
/**
* Kirajzolja a megadott koordinátákra a megfelelő mezőt
* @param y y koordináta
* @param x x koordináta
*/
public
static
void
drawRequiredFor
(
int
y
,
int
x
)
public
static
void
drawRequiredFor
(
int
y
,
int
x
)
{
{
AbstractField
af
=
map
.
get
(
"f_"
+
y
+
"_"
+
x
);
AbstractField
af
=
map
.
get
(
"f_"
+
y
+
"_"
+
x
);
...
@@ -231,6 +240,9 @@ public class Main extends Application {
...
@@ -231,6 +240,9 @@ public class Main extends Application {
crates
.
remove
(
getKeyByValue
(
crates
,
c
));
crates
.
remove
(
getKeyByValue
(
crates
,
c
));
}
}
/**
* Ellenőrzi, hogy vége-e a játéknak
*/
private
static
void
checkGameEnded
()
{
private
static
void
checkGameEnded
()
{
if
(
aliveWorkers
.
size
()
==
0
)
{
if
(
aliveWorkers
.
size
()
==
0
)
{
endGame
();
endGame
();
...
@@ -247,10 +259,17 @@ public class Main extends Application {
...
@@ -247,10 +259,17 @@ public class Main extends Application {
}
}
}
}
/**
* Jelzi, hogy vége a játéknak
*/
private
static
void
endGame
()
{
private
static
void
endGame
()
{
gameRunning
=
false
;
gameRunning
=
false
;
}
}
/**
* Visszaadja, hogy megy-e még a játék
* @return
*/
public
static
boolean
isGameRunning
()
{
return
gameRunning
;
}
public
static
boolean
isGameRunning
()
{
return
gameRunning
;
}
private
static
void
runCommand
(
String
cmdline
)
throws
NumberFormatException
,
IOException
private
static
void
runCommand
(
String
cmdline
)
throws
NumberFormatException
,
IOException
...
@@ -300,6 +319,12 @@ public class Main extends Application {
...
@@ -300,6 +319,12 @@ public class Main extends Application {
}
}
/**
* Létrehozza a pályát
* @param lines beolvasott sorok száma
* @param columns beolvasott oszlopok száma
* @throws IOException
*/
private
static
void
parseMap
(
int
lines
,
int
columns
)
throws
IOException
{
private
static
void
parseMap
(
int
lines
,
int
columns
)
throws
IOException
{
//Tisztítás
//Tisztítás
map
.
clear
();
map
.
clear
();
...
@@ -365,6 +390,12 @@ public class Main extends Application {
...
@@ -365,6 +390,12 @@ public class Main extends Application {
view
.
init
(
lines
,
columns
);
view
.
init
(
lines
,
columns
);
}
}
/**
* Létrehoz egy munkást a megadott paraméterekkel, hozzáadja workers adattaghoz, és ráállítja a megfelelő mezőre
* @param name munkás neve
* @param force munkás ereje
* @param field munkás mezője
*/
private
static
void
spawnWorker
(
String
name
,
double
force
,
String
field
)
private
static
void
spawnWorker
(
String
name
,
double
force
,
String
field
)
{
{
Worker
w
=
new
Worker
(
force
);
Worker
w
=
new
Worker
(
force
);
...
@@ -374,6 +405,11 @@ public class Main extends Application {
...
@@ -374,6 +405,11 @@ public class Main extends Application {
f
.
accept
(
Direction
.
RIGHT
,
w
,
w
);
f
.
accept
(
Direction
.
RIGHT
,
w
,
w
);
}
}
/**
* Létrehoz egy ládát, hozzáadja a crates adattaghoz, és ráállítja a megfelelő mezőre.
* @param name láda neve
* @param field láda mezője
*/
private
static
void
spawnCrate
(
String
name
,
String
field
)
private
static
void
spawnCrate
(
String
name
,
String
field
)
{
{
Crate
c
=
new
Crate
();
Crate
c
=
new
Crate
();
...
@@ -382,11 +418,21 @@ public class Main extends Application {
...
@@ -382,11 +418,21 @@ public class Main extends Application {
f
.
accept
(
Direction
.
RIGHT
,
new
Worker
(
0
),
c
);
f
.
accept
(
Direction
.
RIGHT
,
new
Worker
(
0
),
c
);
}
}
/**
* A megadott SwitchField-et ráállítja a megadott SwitchableHole-ra
* @param shole SwitchableHole
* @param mySwitch SwitchField
*/
private
static
void
setSwitch
(
String
shole
,
String
mySwitch
)
private
static
void
setSwitch
(
String
shole
,
String
mySwitch
)
{
{
((
SwitchField
)
map
.
get
(
mySwitch
)).
setSHole
((
SwitchableHole
)
map
.
get
(
shole
));
((
SwitchField
)
map
.
get
(
mySwitch
)).
setSHole
((
SwitchableHole
)
map
.
get
(
shole
));
}
}
/**
* A megadott mezőre mézet helyez, ha a fluid ‘h’ és olajat, ha az ‘o’
* @param field megadott mező
* @param fluid olaj vagy méz
*/
private
static
void
putFluid
(
String
field
,
char
fluid
)
private
static
void
putFluid
(
String
field
,
char
fluid
)
{
{
SimpleField
sf
=((
SimpleField
)
map
.
get
(
field
));
SimpleField
sf
=((
SimpleField
)
map
.
get
(
field
));
...
@@ -398,12 +444,21 @@ public class Main extends Application {
...
@@ -398,12 +444,21 @@ public class Main extends Application {
System
.
out
.
println
(
"you can only choose either 'h' or 'o'"
);
System
.
out
.
println
(
"you can only choose either 'h' or 'o'"
);
}
}
/**
* A megadott munkást a megadott irányba próbálja léptetni
* @param worker megadott munkás
* @param toward merre lépjen
*/
private
static
void
step
(
String
worker
,
String
toward
)
private
static
void
step
(
String
worker
,
String
toward
)
{
{
Worker
w
=
(
Worker
)
workers
.
get
(
worker
);
Worker
w
=
(
Worker
)
workers
.
get
(
worker
);
w
.
step
(
Direction
.
fromString
(
toward
));
w
.
step
(
Direction
.
fromString
(
toward
));
}
}
/**
* Megkeresi, hogy milyen pályán lévő dolog nevét kapta paraméterül
* @param object pályán lévő dolog
*/
private
static
void
stat
(
String
object
)
private
static
void
stat
(
String
object
)
{
{
if
(
map
.
containsKey
(
object
))
if
(
map
.
containsKey
(
object
))
...
@@ -424,10 +479,19 @@ public class Main extends Application {
...
@@ -424,10 +479,19 @@ public class Main extends Application {
}
}
}
}
/**
* Sarkokat beállítja a megadott mezőn
* @param field megadott mező
*/
private
static
void
setCorner
(
String
field
)
{
private
static
void
setCorner
(
String
field
)
{
map
.
get
(
field
).
setToCorner
();
map
.
get
(
field
).
setToCorner
();
}
}
/**
* Beolvassa a fájlnévvel megadott fájlt, és soronként lefuttatja azt a runCommand() függvénnyel
* @param file fájlnév
* @throws IOException
*/
private
static
void
script
(
String
file
)
throws
IOException
private
static
void
script
(
String
file
)
throws
IOException
{
{
BufferedReader
backup
=
br
;
BufferedReader
backup
=
br
;
...
...
This diff is collapsed.
Click to expand it.
src/killer_sokoban/View.java
+
51
−
0
View file @
a8528239
...
@@ -29,6 +29,11 @@ public class View {
...
@@ -29,6 +29,11 @@ public class View {
Text
w1FinalScore
;
Text
w1FinalScore
;
Text
w2FinalScore
;
Text
w2FinalScore
;
/**
* A megjelenítendő pálya paramétereinek megadása
* @param line pálya sorainak száma
* @param column pálya oszlopainak a száma
*/
public
void
init
(
int
line
,
int
column
)
public
void
init
(
int
line
,
int
column
)
{
{
this
.
line
=
line
;
this
.
line
=
line
;
...
@@ -37,11 +42,19 @@ public class View {
...
@@ -37,11 +42,19 @@ public class View {
gc
.
getCanvas
().
setWidth
(
tileSize
*
column
);
gc
.
getCanvas
().
setWidth
(
tileSize
*
column
);
gc
.
getCanvas
().
setHeight
(
tileSize
*
line
);
gc
.
getCanvas
().
setHeight
(
tileSize
*
line
);
}
}
/**
* vászon beállítása, amire a View rajzol
* @param c vászon
*/
public
void
setCanvas
(
Canvas
c
)
public
void
setCanvas
(
Canvas
c
)
{
{
this
.
gc
=
c
.
getGraphicsContext2D
();
this
.
gc
=
c
.
getGraphicsContext2D
();
}
}
/**
* A pálya minden elemének újrarajzolása
*/
public
void
update
()
public
void
update
()
{
{
//gc.clearRect(0, 0, column*tileSize, line*tileSize);
//gc.clearRect(0, 0, column*tileSize, line*tileSize);
...
@@ -64,40 +77,78 @@ public class View {
...
@@ -64,40 +77,78 @@ public class View {
}
}
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre az Abstractfieldnek megfelelő grafikus elem kirajzolása
*/
public
void
drawAbstract
()
{
public
void
drawAbstract
()
{
gc
.
setLineWidth
(
0.1
);
gc
.
setLineWidth
(
0.1
);
gc
.
setStroke
(
Color
.
BLUE
);
gc
.
setStroke
(
Color
.
BLUE
);
gc
.
strokeRect
(
x
*
tileSize
,
y
*
tileSize
,
tileSize
,
tileSize
);
gc
.
strokeRect
(
x
*
tileSize
,
y
*
tileSize
,
tileSize
,
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a SimpleField-nek megfelelő grafikus elem kirajzolása
*/
public
void
drawSimpleField
()
{
public
void
drawSimpleField
()
{
//gc.drawImage(simpleFieldImg, x*tileSize, y*tileSize);
//gc.drawImage(simpleFieldImg, x*tileSize, y*tileSize);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a TargetField-nek megfelelő grafikus elem kirajzolása
*/
public
void
drawTargetField
()
{
public
void
drawTargetField
()
{
gc
.
drawImage
(
targetFieldImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
targetFieldImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/*
* Az x, y koordinátákkal meghatározott mezőre a Hole-nak megfelelő grafikus elem kirajzolása
*/
public
void
drawHole
()
{
public
void
drawHole
()
{
gc
.
drawImage
(
holeImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
holeImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a SwitchField-nek megfelelő grafikus elem kirajzolása
*/
public
void
drawSwitchField
()
{
public
void
drawSwitchField
()
{
gc
.
drawImage
(
switchFieldImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
switchFieldImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a Wall-nek megfelelő grafikus elem kirajzolása
*/
public
void
drawWall
()
{
public
void
drawWall
()
{
gc
.
drawImage
(
wallImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
wallImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a Oil-nak megfelelő grafikus elem kirajzolása (a már ott lévő tetejére, amely még kilátszik alóla)
*/
public
void
drawOil
()
{
public
void
drawOil
()
{
gc
.
drawImage
(
oilImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
oilImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a Honey-nak megfelelő grafikus elem kirajzolása (a már ott lévő tetejére, amely még kilátszik alóla)
*/
public
void
drawHoney
()
{
public
void
drawHoney
()
{
gc
.
drawImage
(
honeyImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
honeyImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a Worker-nek megfelelő grafikus elem kirajzolása
* @param w a kirajzolandó munkás
*/
public
void
drawWorker
(
Worker
w
)
{
public
void
drawWorker
(
Worker
w
)
{
String
name
=
Main
.
getMoveableName
(
w
);
String
name
=
Main
.
getMoveableName
(
w
);
Image
wImg
=
new
Image
(
"file:GIMPimages/"
+
name
+
".png"
);
Image
wImg
=
new
Image
(
"file:GIMPimages/"
+
name
+
".png"
);
gc
.
drawImage
(
wImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
wImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
/**
* Az x, y koordinátákkal meghatározott mezőre a Crate-nek megfelelő grafikus elem kirajzolása
*/
public
void
drawCrate
()
{
public
void
drawCrate
()
{
gc
.
drawImage
(
crateImg
,
x
*
tileSize
,
y
*
tileSize
);
gc
.
drawImage
(
crateImg
,
x
*
tileSize
,
y
*
tileSize
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment