Skip to content
Snippets Groups Projects
Commit bb92e7b6 authored by gulyasgabormate's avatar gulyasgabormate
Browse files

Master

parents
No related branches found
No related tags found
No related merge requests found
# Auto detect text files and perform LF normalization
* text=auto
File added
File added
# Killer_Sokoban
18 13
w w w w w w w w w w w w w w w w w w
w f f f f f f f f f f h f f f t t w
w f s f f f f f f f f h f f f t t w
w f f f f f f f f f f h f f f t t w
w f f f f f f f f f f h f f f t t w
w f s f f f f f f f f h f f f t t w
w f f f f f f f f f f h f f f f f w
w f f f f f f f f f f h f f f f f w
w f f f f f f f f f f h f f f f f w
w f f f f f f f f f f h h h h f h w
w f f f f f f f f f f f f f f f f w
w f f f f f f f f f f f f f f f f w
w w w w w w w w w w w w w w w w w w
s 2 2 11 2
s 2 5 11 5
b 3 2 b1
b 5 2 b2
b 3 4 b3
b 5 4 b4
b 3 6 b5
b 5 6 b6
b 3 8 b7
b 5 8 b8
b 3 10 b9
b 5 10 b10
p 1 1 2 p1
p 1 8 2 p2
p 1 3 2 p3
p 1 5 2 p4
p 1 4 2 p5
p 1 2 2 p6
p 1 7 2 p7
p 1 6 2 p8
\ No newline at end of file
18 13
w w w w w w w w w w w w w w w w w w
w w t t t w w w w w w w w w w w w w
w t t t t t w w f f f w w w w f f w
w t f t f t h f f f f f f f s f f w
w t f f f t w w f f f f f f f f f w
w w f f f w w w w f f f f w w f f w
w w w f w w w w w w f f f w w f f w
w w w f w w w w w w w f f f f f f w
w f f f f f w w w w w w f f f f f w
w f f f f f f f f f f f f f f f f w
w f f f f f f f f f f f f f f f f w
w f f f f f w w w w w w w w w w w w
w w w w w w w w w w w w w w w w w w
s 14 3 6 3
b 2 3 b1
b 2 9 b2
b 3 9 b3
b 2 10 b4
b 3 10 b5
b 13 4 b6
b 14 4 b7
b 12 5 b8
b 12 6 b9
b 14 8 b10
b 15 8 b11
b 14 9 b12
b 15 9 b13
p 1 2 2 p1
p 2 2 2 p2
p 3 2 2 p3
p 1 3 2 p4
p 3 3 2 p5
p 1 4 2 p6
p 2 4 2 p7
p 3 4 2 p8
\ No newline at end of file
18 13
w w w w w w w w w w w w w w w w w w
w f f f f f f f f f f f f f f f f w
w f f f h f f f f f f f h f f f f w
w f f f h f f f f f f f h f t f f w
w f f f h f f f f f f f h f t f f w
w f f f h f f f f f f f h f t f f w
w f f f f f f f f f f f f f f f f w
w f f f h f t f f f f f h f f f f w
w f f f h f t f f f f f h f f f f w
w f f f h f t f f f f f h f f f f w
w f f f h f t f f f f f h t t f f w
w f f f f f f f f f f f f f f f f w
w w w w w w w w w w w w w w w w w w
b 9 2 b1
b 9 3 b2
b 9 4 b3
b 9 5 b4
b 9 6 b5
b 9 7 b6
b 9 8 b7
b 9 9 b8
b 9 10 b9
p 1 1 2 p1
p 1 8 2 p2
p 1 3 2 p3
p 1 5 2 p4
p 1 4 2 p5
p 1 2 2 p6
p 1 7 2 p7
p 1 6 2 p8
\ No newline at end of file
18 13
w w w w w w w w w w w w w w w w w w
w w w w w w w w w w w w w w w w w w
w w w w w w w w w w w w w w w w w w
w t f f f f f f f f f f t w w w w w
w f f f f f h f f f f f f w w w w w
w f f f h f f f h f h f w w w w w w
w f h f f f f f f f f f f w w w w w
w f f f f f h f h f f h f w h h h w
w f f h f f f f f f h f f w h w w w
w t f f f f f f f f f f t w h h h w
w w w w w w w w w w w w w w h w w w
w w w w w w w w w w w w w w h h h w
w w w w w w w w w w w w w w w w w w
b 3 7 b1
b 7 6 b2
b 9 4 b3
b 8 8 b4
p 3 3 2 p1
p 6 3 2 p2
p 8 3 2 p3
p 10 3 2 p4
p 3 9 2 p5
p 6 9 2 p6
p 8 9 2 p7
p 10 9 2 p8
\ No newline at end of file
/**
* <h1>Action osztaly</h1>
* Enumeracio, az Accept es a Request fuggvenyek visszateresi erteke.
*/
public enum Action {
/**
* Az objekum nem mozog
*/
Stay,
/**
* Az objektum lep egyet
*/
Step,
/**
* Az objektum lep s a mozgast indito jatekos pontot kap
*/
Increase,
/**
* Az objektum mozog es a mozgast indito jatekos pontot veszit
*/
Decrease,
/**
* Az objektumot megprobaljuk megolni
*/
Kill
}
/**
* <h1>Box osztaly</h1>
* A jatekban a ladat reprezentalo osztaly.
* Kommunikal az alatta levo padloval.
*/
public abstract class Box extends Thing {
/**
* Igaz, ha a lada mar nem mozgathato
*/
private boolean cantMove;
/**
* A lada tomege
*/
private double mass;
/**
* Igaz, ha a lada celmezon van.
*/
public boolean onTarget = false;
/**
* Letrehozza a ladat
* @param m A lada tomege
*/
public Box(double m) {
mass = m;
}
/**
* Az objektum lekerul a palyarol, a floor attributum erteket null-ra allitja.
*/
@Override
public void Die() {
this.floor = null;
cantMove = true;
}
/**
* Meghivja a regi floor Release fuggvenyet, majd meghivja az uj floor Push fuggvenyet
* @param floor Az lada uj mezoje
*/
@Override
public void Enter(Floor floor) {
if(this.floor != null)
this.floor.Release();
this.floor = floor;
this.floor.Push(mass);
}
/**
* Lekerdezi, hogy a lada mozgathato-e
* @return Igaz, ha a lada mozgathato meg
*/
@Override
public boolean IsPushable() {
return !cantMove;
}
/**
* Lekerdezi, hogy a lada eltarolt-e pontot
* 0, ha a lada meg mozgathato
* 1, ha a lada mar nem mozgathato, vagy nincs a palyan
* @return 0 vagy 1 a fenti leiras szerint
*/
@Override
public int GetPoint() {
if(cantMove == true && !onTarget) {
return 1;
}else {
return 0;
}
}
/**
* Beallitja a cantMove parameter erteket, attol fuggoen, hogy a szomszedos mezokon allo Thing-ek mozgathatoak-e
*/
@Override
public void SetMove() {
if (this.floor == null) {
cantMove = true;
return;
}
if ((this.floor.GetNeighbour(Direction.Up).IsThingMovable() == false && this.floor.GetNeighbour(Direction.Right).IsThingMovable() == false) ||
(this.floor.GetNeighbour(Direction.Up).IsThingMovable() == false && this.floor.GetNeighbour(Direction.Left).IsThingMovable() == false) ||
(this.floor.GetNeighbour(Direction.Down).IsThingMovable() == false && this.floor.GetNeighbour(Direction.Right).IsThingMovable() == false) ||
(this.floor.GetNeighbour(Direction.Down).IsThingMovable() == false && this.floor.GetNeighbour(Direction.Left).IsThingMovable() == false))
{
cantMove = true;
}
}
/**
* Lekerdezheto, hogy a lada meg mozoghat-e
* @return Igaz, ha a lada meg mozoghat
*/
@Override
public boolean IsMovable() {
return !cantMove;
}
/**
* A ladat nem lehet megolni, ezert nem csinal semmit
* @return false, mert nem sikerult a muvelet
*/
@Override
public boolean Kill() {
return false;
}
/**
* Megvaltoztatja az onTarget erteket
*/
@Override
public void OnTarget() {
onTarget = !onTarget;
}
}
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
/**
* <h1>BoxIO osztaly</h1>
* A Box osztaly Input-Output osztalya.
* A Box-szal kapcsolatos uzenetek kiirasaert felel.
*/
public class BoxView extends Box
{
/**
* A ladahoz tartozo kep
*/
private Image image;
/**
* Konstruktor
* @param image A lada kepe
* @param mass A lada sulya
*/
public BoxView(Image image, double mass) {
super(mass);
this.image = image;
}
/**
* Kirajzolja a Box-ot
* @param view Ide rajzolodik ki a Box
*/
@Override
public void Draw(ImageView view) {
view.setImage(image);
}
}
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* <h1>Controller osztaly</h1>
* A kapott parancsokat ertelmezi s vegrehajta, valamint lefuttatja az automatikus teszteseteket.
*/
public class Controller
{
/**
* Playereket tarolja
*/
private ArrayList<PlayerView> players;
/**
* A Map-et tarolja
*/
private Map map;
/**
* A GetPlayer fuggvenyben az aktualis player sorszama
*/
private int act = 0;
/**
* Letrehozza a Controller osztalyt
*/
public Controller() {
players = new ArrayList<PlayerView>();
}
/**
* Map-et ad a Controller-hez
* @param m A Controller-hez adott Map
*/
public void AddMap(Map m)
{
map = m;
}
/**
* Player-t ad a Controllerhez
* @param p A Controller-hez adott Player
*/
public void AddPlayer(PlayerView p)
{
players.add(p);
}
/**
* Bejarja a players tombot es egyesevel visszaadja a benne levo PlayerView-kat
* @return A kovetkezo PlayerView
*/
public PlayerView GetPlayer()
{
if (act < players.size()) {
return players.get(act++);
}
act = 0;
return null;
}
/**
* Torli a jatekosokat es az act erteket is 0-ra allitja
*/
public void Clear()
{
act = 0;
players.clear();
}
/**
* A jatekosokat mozgato fuggveny
* @param command A lenyomott billentyu kodja
* @return A jatekallapota
*/
public GameStatus Act(String command)
{
if (command.equals("ESCAPE")) {
return GameStatus.MainMenu;
}
if (players.get(0) != null) {
players.get(0).PressedKey(command);
}
if (players.size() > 1 && players.get(1) != null) {
players.get(1).PressedKey(command);
}
if (players.size() > 2 && players.get(2) != null) {
players.get(2).PressedKey(command);
}
if (players.size() > 3 && players.get(3) != null) {
players.get(3).PressedKey(command);
}
if (players.size() > 4 && players.get(4) != null) {
players.get(4).PressedKey(command);
}
if (players.size() > 5 && players.get(5) != null) {
players.get(5).PressedKey(command);
}
if (players.size() > 6 && players.get(6) != null) {
players.get(6).PressedKey(command);
}
if (players.size() > 7 && players.get(7) != null) {
players.get(7).PressedKey(command);
}
if (map.IsGameOver(this))
{
return GameStatus.Winner;
}
return GameStatus.Game;
}
/**
* Megkeresi a jatekban a legtobb pontot szerzett jatekost
* @return A legtobb pontot szerzett PlayerView
*/
public PlayerView getWinner()
{
PlayerView p = players.get(0);
for (int i = 1; i < players.size(); i++)
{
if (p.GetPoint() < players.get(i).GetPoint())
{
p = players.get(i);
}
}
return p;
}
}
\ No newline at end of file
/**
* <h1>Direction osztaly</h1>
* Iranyokat jeloli enum
*/
public enum Direction {
/**
* Fel
*/
Up,
/**
* Le
*/
Down,
/**
* Balra
*/
Left,
/**
* Jobbra
*/
Right
}
import javafx.scene.image.ImageView;
/**
* Rajzolhato osztalyok kozos interface-e
*/
public interface DrawableThing {
/**
* A kirajzolast vegzo Draw fuggveny
* @param view A mezo amire a kirajzolast kell vegezni
*/
void Draw(ImageView view);
}
import java.util.HashMap;
/**
* <h1>Floor osztaly</h1>
* Egyszeru padloelem.
* Felelossege nyilvantartani szomszedjait,
* kommunikalni a rajta levo objektumokkal es a szomszedjaival.
*/
public class Floor {
/**
* Padlon levo dolog
*/
protected Thing thing;
/**
* Szomszed padloelemek
*/
protected HashMap<Direction, Floor> neighbors;
/**
* Mezon levo kenoanyag
*/
protected Substance status;
/**
* A mezo surlodasa
*/
protected double friction;
/**
* Konstruktor
*/
public Floor() {
neighbors = new HashMap<Direction, Floor>();
status = Substance.Empty;
friction = 0;
}
/**
* Ha nincs rajta semmi, atveszi a parameterkent kapott objektumot,
* kulonben az adott iranyba eso szomszedjanak meghivja az Accept fuggvenyet a rajta levo objektummal
* es a megfelelo irannyal.
* A kapott visszateresi ertektol fuggoen ha ez Step, Increase vagy Decrease,
* akkor atveszi a parameterkent kapott objektumot, kulonben nem veszi at,
* hanem visszaadja a kapott visszateresi erteket.
* @param thing A mezore lepo Thing
* @param direction Az irany amerre tovabb kell kerdezni a mozgast
* @param force A mozgast indito jatekos ereje
* @return A vegrehajtando Action
*/
public Action Accept(Thing thing, Direction direction, double force) {
Action action = Action.Stay;
if(this.thing == null){
if(force >= 0) {
this.thing = thing;
thing.Enter(this);
action = Action.Step;
}
}else {
action = neighbors.get(direction).Accept(this.thing, direction, force - friction); //Accept tovabbhivasa
if((action== Action.Step || action==Action.Increase || action==Action.Decrease) && force >= 0)
{
this.thing = thing;
thing.Enter(this);
}else if(action == Action.Kill && force >= 0) {
if(this.thing.Kill() == true) {
this.thing = thing;
thing.Enter(this);
action = Action.Step;
}else {
action = Action.Kill;
}
}
}
return action;
}
/**
* Meghivja az adott iranyba eso szomszedjanak IsThingPushable fuggvenyet.
* Ha ez true, akkor meghivjuk ugyanazon szomszed Accept fuggvenyet, visszater a kapott Actionnel, kiveve ha ez Kill,
* ekkor Stayt ad vissza, valamint ha az IsThingPushable visszateresi erteke false.
* @param direction Az irany, amerre a mozgast inditja jatekos
* @param force A mozgast indito jatekos ereje
* @return A vegrehajtando Action
*/
public Action Request(Direction direction, double force) {
if(neighbors.get(direction).IsThingPushable()) {
Action action = neighbors.get(direction).Accept(this.thing, direction, force);
if(action != Action.Kill && action != Action.Stay) {
thing = null;
return action;
}
else return Action.Stay;
}
else
return Action.Stay;
}
/**
* Meghivodik, ha egy objektum ralep. A specialis mezok itt vegzik el a feladatukat.
* @param mass A ra levo objektum tomege
*/
public void Push(double mass) {
switch (status){
case Oil:
friction = 0.5 * mass;
break;
case Honey:
friction = 1.5 * mass;
break;
case Empty:
friction = mass;
break;
}
}
/**
* Meghvdik, ha az objektum lelep rola. A specialis mezok itt vegzik el a feladatukat.
*/
public void Release() {
friction = 0;
}
/**
* Visszaadja a rajta levo objektum IsPushable fuggvenyenek visszateresi erteket,
* ha nincs rajta objektum, igazzal ter vissza.
* @return Igaz, ha a rajta levo objektum tolhato
*/
public boolean IsThingPushable() {
if (thing == null)
return true;
return thing.IsPushable();
}
/**
* Visszaadja a rajta lv objektum IsMovable fggvnynek visszatrsi rtkt,
* ha nincs rajta objektum, igazzal tr vissza.
* @return Igaz, ha a rajta levo objektum mozgathato
*/
public boolean IsThingMovable() {
if (thing == null)
return true;
return thing.IsMovable();
}
/**
* Bealltja a parameterul kapott objektumot a kapott iranyu szomszedjanak.
* @param floor A szomszedos mezo
* @param direction Az szomszedos mezo iranya
*/
public void SetNeighbour(Floor floor, Direction direction) {
neighbors.put(direction, floor);
switch (direction){
case Up:
if(floor.GetNeighbour(Direction.Down) != this)
floor.SetNeighbour(this, Direction.Down);
break;
case Down:
if(floor.GetNeighbour(Direction.Up) != this)
floor.SetNeighbour(this, Direction.Up);
break;
case Right:
if(floor.GetNeighbour(Direction.Left) != this)
floor.SetNeighbour(this, Direction.Left);
break;
case Left:
if(floor.GetNeighbour(Direction.Right) != this)
floor.SetNeighbour(this, Direction.Right);
break;
}
}
/**
* A mezore rakjuk a thing-et
* @param thing A mezore kerulo Thing
*/
public void SetThing(Thing thing) {
this.thing = thing;
}
/**
* Visszaadja a kapott iranyban levo szomszedjat.
* @param direction A mezo iranya
* @return Az adott iranyban levo szomszedos mezo
*/
public Floor GetNeighbour(Direction direction) {
return neighbors.get(direction);
}
/**
* A mezore kenoanyagot helyez el
* @param sub A mezore kerulo parameter
*/
public void SetStatus(Substance sub) {
status = sub;
}
}
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
/**
* Floor-ok View osztalya
*/
public class FloorView extends Floor {
/**
* A Floor-okhoz tartozo Image-ek
*/
private Image activeImage, defaultImage, honey, oil;
/**
* A mezo ImageView osztalya
*/
private ImageView view;
/**
* A mezo felett levo ImageView osztaly
*/
private ImageView topView;
/**
* Az osztaly konstruktora
* @param image A Floor default Image-e
* @param h A Floor mezes Image-e
* @param o A Floor olajos Image-e
* @param view A Floor mezo ImageView osztalya
* @param topView A Floor mezo feletti ImageView osztaly
*/
public FloorView(Image image, Image h, Image o, ImageView view, ImageView topView)
{
this.defaultImage = image;
this.honey = h;
this.oil = o;
this.view = view;
this.topView = topView;
this.activeImage = defaultImage;
view.setImage(activeImage);
}
/**
* Meghivja az ose SetThing fuggvenyet,
* kirajzolja a topView-ra a kapott thing-et.
* @param thing A mezore kerulo Thing
*/
@Override
public void SetThing(Thing thing) {
super.SetThing(thing);
thing.Draw(topView);
}
/**
* Meghivja az ose Accept fuggvenyet,
* es elvegzi a kiralyzolast.
* @param thing A mezore lepo Thing
* @param d Az irany amerre a kerest tovabbithatja
* @param force A mozgast indito jatekos ereje
* @return Az elvegzendo Action
*/
@Override
public Action Accept(Thing thing, Direction d, double force)
{
Action re = super.Accept(thing, d, force);
view.setImage(activeImage);
if(this.thing != null) {
this.thing.Draw(topView);
}else {
topView.setImage(null);
}
return re;
}
/**
* Meghivja az ose Request fuggvenyet,
* es elvegzi a kirajzolast.
* @param d Az irany amely fele a hivast inditania kell
* @param force A mozgast indito jatekos ereje
* @return Az elvegzendo Action
*/
@Override
public Action Request(Direction d, double force)
{
Action re = super.Request(d, force);
view.setImage(activeImage);
if(this.thing != null) {
this.thing.Draw(topView);
}else {
topView.setImage(null);
}
return re;
}
/**
* Meghivja az ose SetStatus fuggvenyet,
* elvegzi a kirajzolast.
* @param sub A mezore kerulo parameter
*/
@Override
public void SetStatus(Substance sub) {
super.SetStatus(sub);
switch (sub) {
case Honey:
this.activeImage = this.honey;
break;
case Oil:
this.activeImage = this.oil;
break;
case Empty:
this.activeImage = this.defaultImage;
default:
break;
}
view.setImage(activeImage);
}
}
This diff is collapsed.
This diff is collapsed.
public enum GameStatus {
/**
* a jatek a fomenuben van
*/
MainMenu,
/**
* a jatek fut
*/
Game,
/**
* a jatekot megnyerte valaki
*/
Winner
}
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUI">
<children>
<Button fx:id="playButton" layoutX="257.0" layoutY="218.0" mnemonicParsing="false" onAction="#playButtonHandle" prefHeight="45.0" prefWidth="126.0" style="-fx-background-color: #2196F3;" text="Play" textFill="WHITE">
<font>
<Font size="18.0" />
</font></Button>
<Button fx:id="quitButton" layoutX="285.0" layoutY="284.0" mnemonicParsing="false" onAction="#quitButtonHandle" prefHeight="25.0" prefWidth="70.0" style="-fx-background-color: #151928;" text="Quit" textFill="WHITE" />
<Label fx:id="winnerLabel" alignment="CENTER" layoutX="196.0" layoutY="138.0" prefHeight="55.0" prefWidth="248.0" textAlignment="CENTER">
<font>
<Font size="17.0" />
</font>
</Label>
</children>
</AnchorPane>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment