├── .mvn ├── jvm.config └── maven.config ├── src ├── main │ ├── resources │ │ └── nonsense │ │ │ └── hamsterrun │ │ │ ├── robbery.jpg │ │ │ ├── sprites │ │ │ ├── fire.png │ │ │ ├── fire1.png │ │ │ ├── fire2.png │ │ │ ├── fire3.png │ │ │ ├── fire4.png │ │ │ ├── fire5.png │ │ │ ├── fire6.png │ │ │ ├── floor.png │ │ │ ├── gate.png │ │ │ ├── glow1.png │ │ │ ├── glow2.png │ │ │ ├── glow3.png │ │ │ ├── glow4.png │ │ │ ├── grass.png │ │ │ ├── repa.png │ │ │ ├── wall.png │ │ │ ├── blades01.png │ │ │ ├── blades02.png │ │ │ ├── blades11.png │ │ │ ├── blades12.png │ │ │ ├── boulder1.png │ │ │ ├── boulder2.png │ │ │ ├── carrot.png │ │ │ ├── flask1.png │ │ │ ├── flask2.png │ │ │ ├── flask3.png │ │ │ ├── okurka.png │ │ │ ├── pepper.png │ │ │ ├── rat │ │ │ │ ├── run1.png │ │ │ │ ├── run2.png │ │ │ │ ├── sit.png │ │ │ │ ├── fall1.png │ │ │ │ ├── fall10.png │ │ │ │ ├── fall2.png │ │ │ │ ├── fall3.png │ │ │ │ ├── fall4.png │ │ │ │ ├── fall5.png │ │ │ │ ├── fall6.png │ │ │ │ ├── fall7.png │ │ │ │ ├── fall8.png │ │ │ │ └── fall9.png │ │ │ ├── salaty.png │ │ │ ├── water1.png │ │ │ ├── water2.png │ │ │ ├── water3.png │ │ │ ├── water4.png │ │ │ ├── aliens │ │ │ │ ├── key.gif │ │ │ │ ├── cat1.gif │ │ │ │ ├── cat2.gif │ │ │ │ ├── falcon.gif │ │ │ │ ├── ghost1.gif │ │ │ │ ├── ghost2.gif │ │ │ │ ├── bigBats.gif │ │ │ │ ├── bigFlies.gif │ │ │ │ ├── boulder.gif │ │ │ │ ├── smallBats.gif │ │ │ │ ├── smallFlies.gif │ │ │ │ └── falcon_shadow.png │ │ │ ├── houbicky1.png │ │ │ ├── houbicky2.png │ │ │ ├── houbicky3.png │ │ │ ├── houbicky4.png │ │ │ ├── sneci │ │ │ │ ├── eat.png │ │ │ │ ├── run1.png │ │ │ │ ├── sit.png │ │ │ │ └── fall1.png │ │ │ ├── trapdoor1.png │ │ │ ├── trapdoor2.png │ │ │ ├── tunnel1off.png │ │ │ ├── tunnel1on.png │ │ │ ├── brownie │ │ │ │ ├── eat.png │ │ │ │ ├── fall1.png │ │ │ │ ├── fall2.png │ │ │ │ ├── fall3.png │ │ │ │ ├── fall4.png │ │ │ │ ├── fall5.png │ │ │ │ ├── fall6.png │ │ │ │ ├── fall7.png │ │ │ │ ├── fall8.png │ │ │ │ ├── fall9.png │ │ │ │ ├── fally.png │ │ │ │ ├── run1.png │ │ │ │ ├── run2.png │ │ │ │ ├── run3.png │ │ │ │ ├── run5.png │ │ │ │ ├── sit.png │ │ │ │ ├── stayX.png │ │ │ │ ├── fall10.png │ │ │ │ └── fallx1.png │ │ │ ├── hnedulka │ │ │ │ ├── eat.png │ │ │ │ ├── run1.png │ │ │ │ ├── run2.png │ │ │ │ ├── run3.png │ │ │ │ ├── run4.png │ │ │ │ ├── run5.png │ │ │ │ ├── run6.png │ │ │ │ ├── run7.png │ │ │ │ ├── runX.png │ │ │ │ ├── runY.png │ │ │ │ ├── sit.png │ │ │ │ ├── fall1.png │ │ │ │ ├── fall10.png │ │ │ │ ├── fall2.png │ │ │ │ ├── fall3.png │ │ │ │ ├── fall4.png │ │ │ │ ├── fall5.png │ │ │ │ ├── fall6.png │ │ │ │ ├── fall7.png │ │ │ │ ├── fall8.png │ │ │ │ ├── fall9.png │ │ │ │ └── fallX.png │ │ │ ├── uhlicek │ │ │ │ ├── eat.png │ │ │ │ ├── fall1.png │ │ │ │ ├── fall2.png │ │ │ │ ├── fall3.png │ │ │ │ ├── fall4.png │ │ │ │ ├── fall5.png │ │ │ │ ├── fall6.png │ │ │ │ ├── fall7.png │ │ │ │ ├── fall8.png │ │ │ │ ├── fall9.png │ │ │ │ ├── fallX.png │ │ │ │ ├── fallY.png │ │ │ │ ├── run1.png │ │ │ │ ├── run2.png │ │ │ │ ├── run3.png │ │ │ │ ├── run4.png │ │ │ │ ├── run5.png │ │ │ │ ├── run6.png │ │ │ │ ├── sit.png │ │ │ │ └── fall10.png │ │ │ ├── virecek │ │ │ │ ├── eat.png │ │ │ │ ├── fall1.png │ │ │ │ ├── fall2.png │ │ │ │ ├── fall3.png │ │ │ │ ├── fall4.png │ │ │ │ ├── fall5.png │ │ │ │ ├── fall6.png │ │ │ │ ├── fall7.png │ │ │ │ ├── fall8.png │ │ │ │ ├── fall9.png │ │ │ │ ├── run1.png │ │ │ │ ├── run10.png │ │ │ │ ├── run2.png │ │ │ │ ├── run3.png │ │ │ │ ├── run4.png │ │ │ │ ├── run5.png │ │ │ │ ├── run6.png │ │ │ │ ├── run7.png │ │ │ │ ├── run8.png │ │ │ │ ├── run9.png │ │ │ │ ├── sit.png │ │ │ │ ├── fall10.png │ │ │ │ └── IMG_3491.png │ │ │ ├── allWayTeleport1.png │ │ │ ├── allWayTeleport2.png │ │ │ ├── allWayTeleport3.png │ │ │ ├── allWayTeleport4.png │ │ │ ├── allWayTeleport5.png │ │ │ ├── allWayTeleport6.png │ │ │ ├── oneWayTeleport1.png │ │ │ ├── oneWayTeleport2.png │ │ │ ├── oneWayTeleport3.png │ │ │ ├── oneWayTeleport4.png │ │ │ ├── oneWayTeleport5.png │ │ │ ├── oneWayTeleport6.png │ │ │ ├── tunnelComposed.png │ │ │ ├── twoWayTeleport1.png │ │ │ ├── twoWayTeleport2.png │ │ │ ├── twoWayTeleport3.png │ │ │ ├── twoWayTeleport4.png │ │ │ ├── twoWayTeleport5.png │ │ │ └── twoWayTeleport6.png │ │ │ ├── sounds │ │ │ └── effects │ │ │ │ ├── chroup.wav │ │ │ │ ├── pisk1.wav │ │ │ │ ├── pisk2.wav │ │ │ │ ├── pisk3.wav │ │ │ │ ├── pisk4.wav │ │ │ │ ├── pisk5.wav │ │ │ │ ├── turbo.wav │ │ │ │ ├── brblibrbli1.wav │ │ │ │ ├── brblibrbli2.wav │ │ │ │ ├── brblibrbli3.wav │ │ │ │ └── brblibrbli4.wav │ │ │ └── preconf │ │ │ ├── traps │ │ │ ├── hunt │ │ │ ├── waterworld │ │ │ ├── fireworld │ │ │ ├── paradise │ │ │ └── hawk │ └── java │ │ └── nonsense │ │ └── hamsterrun │ │ ├── setup │ │ ├── Localized.java │ │ ├── PresetConfigs.java │ │ └── SetupWindow.java │ │ ├── network │ │ ├── Commands.java │ │ └── HelloCmd.java │ │ ├── env │ │ ├── traps │ │ │ ├── Relocator.java │ │ │ ├── Cucumber.java │ │ │ ├── Carrot.java │ │ │ ├── Empty.java │ │ │ ├── Item.java │ │ │ ├── Salat.java │ │ │ ├── Repa.java │ │ │ ├── Grass.java │ │ │ ├── AnimationCounrer.java │ │ │ ├── Pepper.java │ │ │ ├── TrapDoor.java │ │ │ ├── OneWayTeleport.java │ │ │ ├── Mushroom.java │ │ │ ├── ColorfullFlask.java │ │ │ ├── Vegetable.java │ │ │ ├── Cage.java │ │ │ ├── AllWayTeleport.java │ │ │ ├── Water.java │ │ │ ├── InvisibleTrapDoor.java │ │ │ ├── Torturer.java │ │ │ ├── Tunnel.java │ │ │ ├── Fire.java │ │ │ └── TwoWayTeleport.java │ │ ├── ThumbnailAble.java │ │ ├── aliens │ │ │ ├── BigBats.java │ │ │ ├── SmallBats.java │ │ │ ├── BigFlies.java │ │ │ ├── SmallFlies.java │ │ │ ├── Cat.java │ │ │ ├── Key.java │ │ │ └── Ghost.java │ │ ├── BlockField.java │ │ ├── ItemsWithBoundaries.java │ │ ├── RatActions.java │ │ ├── SoundsBuffer.java │ │ └── WavSoundPlayer.java │ │ ├── ratcontroll │ │ ├── KeyboardControl.java │ │ ├── RatsProvider.java │ │ ├── Score.java │ │ ├── KeyboardControl0.java │ │ ├── HighScore.java │ │ ├── KeyboardControl2.java │ │ ├── KeyboardControl3.java │ │ ├── ComputerControl2.java │ │ ├── KeyboardControl1.java │ │ ├── HumanControl.java │ │ ├── MouseControl.java │ │ ├── ScoreListener.java │ │ └── RatsController.java │ │ ├── RatSetup.java │ │ ├── WorldControl.java │ │ ├── sprites │ │ ├── RatSpriteSet.java │ │ └── GifToImages.java │ │ ├── Utils.java │ │ ├── VirtualRatSetup.java │ │ └── Localization.java └── test │ └── java │ └── nonsense │ └── hamsterrun │ ├── BaseConfigTest.java │ ├── env │ └── GifToImagesTest.java │ └── UtilsTest.java ├── deploy.sh ├── .gitignore ├── LICENSE ├── README.md └── pom.xml /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/robbery.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/robbery.jpg -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/fire6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/fire6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/floor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/floor.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/gate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/gate.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/glow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/glow1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/glow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/glow2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/glow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/glow3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/glow4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/glow4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/grass.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/repa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/repa.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/wall.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/blades01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/blades01.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/blades02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/blades02.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/blades11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/blades11.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/blades12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/blades12.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/boulder1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/boulder1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/boulder2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/boulder2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/carrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/carrot.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/flask1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/flask1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/flask2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/flask2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/flask3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/flask3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/okurka.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/okurka.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/pepper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/pepper.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/run2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/salaty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/salaty.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/water1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/water1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/water2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/water2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/water3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/water3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/water4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/water4.png -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/setup/Localized.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.setup; 2 | 3 | public interface Localized { 4 | 5 | public void setTitles(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/key.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/key.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/houbicky1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/houbicky1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/houbicky2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/houbicky2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/houbicky3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/houbicky3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/houbicky4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/houbicky4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/rat/fall9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/rat/fall9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/sneci/eat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/sneci/eat.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/sneci/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/sneci/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/sneci/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/sneci/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/trapdoor1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/trapdoor1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/trapdoor2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/trapdoor2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/tunnel1off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/tunnel1off.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/tunnel1on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/tunnel1on.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/chroup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/chroup.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/pisk1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/pisk1.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/pisk2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/pisk2.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/pisk3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/pisk3.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/pisk4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/pisk4.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/pisk5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/pisk5.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/turbo.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/turbo.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/cat1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/cat1.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/cat2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/cat2.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/falcon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/falcon.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/ghost1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/ghost1.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/ghost2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/ghost2.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/eat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/eat.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fally.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fally.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/run2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/run3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/run3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/run5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/run5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/stayX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/stayX.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/eat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/eat.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/run7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/runX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/runX.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/runY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/runY.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/sneci/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/sneci/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/eat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/eat.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fallX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fallX.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fallY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fallY.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/run6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/eat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/eat.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/run9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/run9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/sit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/sit.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/bigBats.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/bigBats.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/bigFlies.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/bigFlies.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/boulder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/boulder.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/allWayTeleport6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fall10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fall10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/brownie/fallx1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/brownie/fallx1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall7.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall8.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fall9.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fallX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/hnedulka/fallX.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/oneWayTeleport6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/tunnelComposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/tunnelComposed.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport1.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport2.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport3.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport4.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport5.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/twoWayTeleport6.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/uhlicek/fall10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/fall10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/fall10.png -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli1.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli2.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli3.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sounds/effects/brblibrbli4.wav -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/smallBats.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/smallBats.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/smallFlies.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/smallFlies.gif -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/virecek/IMG_3491.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/virecek/IMG_3491.png -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/network/Commands.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.network; 2 | 3 | public class Commands { 4 | 5 | public static final String HANDSHAKE = "hello "; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/sprites/aliens/falcon_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/judovana/HamsterRun/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/falcon_shadow.png -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | DISPLAY=:0 mvn clean install 2 | scp $HOME/.m2/repository/com/google/code/gson/gson/2.13.1/gson-2.13.1.jar kino.local:/$HOME/gson-2.13.1.jar 3 | scp $HOME/git/HamsterRun/target/hamsterrun-1.0-SNAPSHOT.jar kino.local:/$HOME/hamsterrun-1.0-SNAPSHOT.jar 4 | 5 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Relocator.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | 7 | public interface Relocator { 8 | 9 | void relocate(World world, Rat rat); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/KeyboardControl.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.event.KeyEvent; 7 | 8 | public abstract class KeyboardControl extends HumanControl { 9 | public abstract void act(Rat rat, KeyEvent e, World world); 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | 26 | target 27 | .idea 28 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/ThumbnailAble.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import java.awt.Graphics2D; 4 | 5 | public interface ThumbnailAble { 6 | 7 | void drawThumbnail(Graphics2D g2d, int size); 8 | 9 | void playMainSoundFor(SoundsBuffer rat); 10 | 11 | default void playSecondarySoundFor(SoundsBuffer rat) { 12 | } 13 | 14 | default void playTercialSoundFor(SoundsBuffer rat) { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/RatsProvider.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | 5 | import java.util.List; 6 | 7 | public interface RatsProvider { 8 | 9 | public List getRats(); 10 | 11 | public RatsController.RatControl getRatControl(Rat rat); 12 | 13 | void swap(Rat rat); 14 | 15 | void kill(); 16 | 17 | void remove(Rat rat, long time); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Cucumber.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Image; 8 | 9 | public class Cucumber extends Vegetable { 10 | 11 | 12 | protected Image getSprite() { 13 | return SpritesProvider.okurka; 14 | } 15 | 16 | public int eat(Rat eater, World world) { 17 | if (eaten()) { 18 | return 0; 19 | } 20 | energy--; 21 | eater.adjustScore(100); 22 | return 100; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Carrot.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Image; 9 | 10 | public class Carrot extends Vegetable { 11 | 12 | 13 | protected Image getSprite() { 14 | return SpritesProvider.carrot; 15 | } 16 | 17 | public int eat(Rat eater, World world) { 18 | if (eaten()) { 19 | return 0; 20 | } 21 | if (seed.nextBoolean()) { 22 | energy--; 23 | eater.adjustScore(200); 24 | return 200; 25 | } else { 26 | eater.setAction(RatActions.WALK); 27 | return 0; 28 | } 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Empty.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | 10 | public class Empty implements Item { 11 | 12 | public Color getMinimapColor() { 13 | return Color.white; 14 | } 15 | 16 | @Override 17 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 18 | 19 | } 20 | 21 | @Override 22 | public void drawThumbnail(Graphics2D g2d, int size) { 23 | g2d.drawImage(SpritesProvider.getFloor(5), 0, 0, size, size, null); 24 | } 25 | 26 | @Override 27 | public void playMainSoundFor(SoundsBuffer rat) { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Item.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.env.ThumbnailAble; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | import java.util.Random; 10 | 11 | //use this in some readme instead of plain doc 12 | public interface Item extends ThumbnailAble { 13 | static final Random seed = new Random(); 14 | 15 | 16 | Color getMinimapColor(); 17 | 18 | 19 | //level: 1 floor, 2 before rats, rats, 3 over rats 20 | //missing somethign between floor and walls.. but nvm... 21 | void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y); 22 | 23 | default void drawMapHighlight(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) {}; 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Salat.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Image; 8 | 9 | //so delicious, that once in process of eating, can not be left 10 | public class Salat extends Vegetable { 11 | 12 | 13 | protected Image getSprite() { 14 | return SpritesProvider.salat; 15 | } 16 | 17 | @Override 18 | protected float getMaxEnergy() { 19 | return 20; 20 | } 21 | 22 | @Override 23 | protected int getStartEnergy() { 24 | return seed.nextInt(((int) (getMaxEnergy() / 2))) + (int) (getMaxEnergy() / 2); 25 | } 26 | 27 | public int eat(Rat eater, World world) { 28 | if (eaten()) { 29 | return 0; 30 | } 31 | energy--; 32 | eater.adjustScore(150); 33 | return 150; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/RatSetup.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import nonsense.hamsterrun.ratcontroll.RatsController; 4 | 5 | 6 | public class RatSetup extends VirtualRatSetup { 7 | 8 | final RatsController.RatControl control; 9 | 10 | 11 | public RatSetup(String def, int aiChaos, boolean display, String skin, RatsController.RatControl control) { 12 | super(def, aiChaos, display, skin, control.id()); 13 | this.control = control; 14 | } 15 | 16 | //syntax control:skin:haveDisplay:aiModifier eg k1:uhlicek:true or pc:rat:false:10 17 | public static RatSetup parse(String def) { 18 | VirtualRatSetup virtualRat = VirtualRatSetup.parse(def); 19 | return new RatSetup(def, virtualRat.aiChaos, virtualRat.display, virtualRat.skin, VirtualRatSetup.stringToRatControl(def, virtualRat.controlDef)); 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return control.id() + ":" + skin + ":" + display + ":" + aiChaos; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Repa.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Image; 9 | 10 | //so hard, that can not be crossed until eaten 11 | public class Repa extends Vegetable { 12 | 13 | private RatActions.Direction lock = null; 14 | 15 | protected Image getSprite() { 16 | return SpritesProvider.repa; 17 | } 18 | 19 | 20 | @Override 21 | protected float getMaxEnergy() { 22 | return 20; 23 | } 24 | 25 | @Override 26 | protected int getStartEnergy() { 27 | return seed.nextInt(((int) (getMaxEnergy() / 2))) + (int) (getMaxEnergy() / 2); 28 | } 29 | 30 | public int eat(Rat eater, World world) { 31 | if (eaten()) { 32 | return 0; 33 | } 34 | energy--; 35 | eater.adjustScore(150); 36 | return 150; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/Score.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | public class Score { 4 | private final String skin; 5 | private final String id; 6 | private final long time; 7 | private final int score; 8 | private final long tscore; 9 | 10 | public Score(String skin, String id, long time, int score, long tscore) { 11 | this.skin = skin; 12 | this.id = id; 13 | this.time = time; 14 | this.score = score; 15 | this.tscore = tscore; 16 | } 17 | 18 | public int getScore() { 19 | return score; 20 | } 21 | 22 | public long getTime() { 23 | return time; 24 | } 25 | 26 | public long getTscore() { 27 | return tscore; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return toTString(""); 33 | } 34 | 35 | public String toTString(String prefix) { 36 | return prefix + "\\o/ " + skin + '/' + id + "at " + (time / 1000 / 60) + "minutes with score of" + score + "/" + tscore; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Grass.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Image; 8 | 9 | //as cucumber, just drawn above 10 | public class Grass extends Vegetable { 11 | 12 | 13 | protected Image getSprite() { 14 | return SpritesProvider.grass; 15 | } 16 | 17 | @Override 18 | protected float getMaxEnergy() { 19 | return 60; 20 | } 21 | 22 | @Override 23 | protected int getStartEnergy() { 24 | return seed.nextInt(((int) (getMaxEnergy() / 2))) + (int) (getMaxEnergy() / 2); 25 | } 26 | 27 | @Override 28 | public boolean eaten() { 29 | return energy < 30; 30 | } 31 | 32 | public int eat(Rat eater, World world) { 33 | if (eaten()) { 34 | return 0; 35 | } 36 | energy--; 37 | eater.adjustScore(50); 38 | return 50; 39 | } 40 | 41 | @Override 42 | protected int targetLevel() { 43 | return 3; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 judovana 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/AnimationCounrer.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | public class AnimationCounrer { 4 | 5 | public int anim = 0; 6 | public int max; 7 | 8 | public AnimationCounrer() { 9 | max = 100; 10 | } 11 | 12 | public AnimationCounrer(int max) { 13 | this.max = max; 14 | } 15 | 16 | public int everyOdd() { 17 | return anim % 2; 18 | } 19 | 20 | public int mod(int i) { 21 | return anim % i; 22 | } 23 | 24 | public int modMap() { 25 | return anim % 15; 26 | } 27 | 28 | public int every10() { 29 | return anim % 10; 30 | } 31 | 32 | public int ignore() { 33 | return 0; 34 | } 35 | 36 | public void addLimited() { 37 | this.anim++; 38 | if (anim >= 100) { 39 | anim = 0; 40 | } 41 | } 42 | 43 | public boolean everyThird() { 44 | return anim % 3 == 0; 45 | } 46 | 47 | public void reset() { 48 | anim = 0; 49 | } 50 | 51 | public void reset(int i) { 52 | anim = i - 1; 53 | addLimited(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Pepper.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Image; 9 | import java.awt.Point; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class Pepper extends Vegetable { 14 | 15 | 16 | protected Image getSprite() { 17 | return SpritesProvider.pepper; 18 | } 19 | 20 | public int eat(Rat eater, World world) { 21 | if (eaten()) { 22 | return 0; 23 | } 24 | if (seed.nextInt(3) != 0) { 25 | energy--; 26 | eater.adjustScore(200); 27 | return 200; 28 | } else { 29 | eater.setAction(RatActions.STAY); 30 | List l = Teleport.getPassableNeighboursForGivenPoint(eater.getUniversalCoords(), world); 31 | if (!l.isEmpty()) { 32 | Collections.shuffle(l); 33 | eater.setUniversalCoords(l.get(0)); 34 | } 35 | return 0; 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/TrapDoor.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.sprites.SpritesProvider; 5 | 6 | import java.awt.Color; 7 | import java.awt.Graphics2D; 8 | 9 | public class TrapDoor extends InvisibleTrapDoor implements Item { 10 | 11 | private int type = seed.nextInt(2); 12 | 13 | public Color getMinimapColor() { 14 | return new Color(230, 255, 0); 15 | } 16 | 17 | @Override 18 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 19 | if (level == 2) { 20 | if (closed) { 21 | g2d.drawImage(SpritesProvider.trapdoor[type], coordx + zoom / 4, coordy + zoom / 4, zoom - zoom / 2, zoom - zoom / 2, null); 22 | } else { 23 | g2d.setColor(new Color(20, 20, 20)); 24 | g2d.fillRect(coordx + zoom / 4, coordy + zoom / 4, zoom - zoom / 2, zoom - zoom / 2); 25 | } 26 | } 27 | } 28 | 29 | @Override 30 | public void drawThumbnail(Graphics2D g2d, int size) { 31 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/KeyboardControl0.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.event.KeyEvent; 7 | 8 | public class KeyboardControl0 extends KeyboardControl { 9 | @Override 10 | public String id() { 11 | return "k0"; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "+ - end, del, home, ins"; 17 | } 18 | 19 | public void act(Rat rat, KeyEvent e, World world) { 20 | if (e.getKeyChar() == '+') { 21 | zoomIn(); 22 | } else if (e.getKeyChar() == '-') { 23 | zoomOut(); 24 | } else if (e.getKeyCode() == KeyEvent.VK_END) { 25 | //we actually need two maps - anymated and non anymated.. what to do with zoom? 26 | //base second zoom here internally? 27 | map = !map; 28 | } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { 29 | world.regenerateAll(); 30 | } 31 | //keep those two? Made it configurable? 32 | //yes! per player? Yes! 33 | else if (e.getKeyCode() == KeyEvent.VK_HOME) { 34 | world.allRatsSpread(true); 35 | } else if (e.getKeyCode() == KeyEvent.VK_INSERT) { 36 | world.allRatsSpread(false); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/WorldControl.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.nio.file.Files; 9 | 10 | import nonsense.hamsterrun.env.World; 11 | 12 | public class WorldControl { 13 | 14 | //idea is: 15 | //new panel in swing join/create (and how many rats to await) + classical urls/ports 16 | //then master will add rats with "NetworkController" 17 | //the master will send serialized world to client 18 | //client wills end keystrokes/mouse movement *results* as declared in RatController 19 | //Currently it StackOverflow in infinite recursion 20 | 21 | 22 | public void sendCatched(World world) { 23 | try { 24 | send(world); 25 | } catch (Exception ex) { 26 | ex.printStackTrace(); 27 | } 28 | 29 | } 30 | 31 | public void send(World world) throws IOException { 32 | GsonBuilder builder = new GsonBuilder(); 33 | builder.registerTypeAdapter(Class.class, new BaseConfig.ClassTypeAdapter()); 34 | builder.setPrettyPrinting(); 35 | Gson gson = builder.create(); 36 | String json = gson.toJson(world, World.class); 37 | Files.writeString(new File("/home/jvanek/Desktop/test.json").toPath(), json); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/OneWayTeleport.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Point; 9 | import java.awt.image.BufferedImage; 10 | 11 | public class OneWayTeleport extends Teleport { 12 | //wil drop the mouse to one bound space. If the space no longer exists (is impassable) 13 | //will move pick up new random spot 14 | 15 | private Point target; 16 | 17 | public Color getMinimapColor() { 18 | return new Color(230, 255, 0); 19 | } 20 | 21 | @Override 22 | protected BufferedImage getSprite(int id) { 23 | return SpritesProvider.getOneWayTeleport(id); 24 | } 25 | 26 | @Override 27 | public void relocate(World world, Rat rat) { 28 | if (target == null) { 29 | InvisibleTrapDoor.randomAloneSpot(world, rat); 30 | target = rat.getUniversalCoords(); 31 | } else { 32 | if (world.getBlockField(target).isPassable()) { 33 | rat.setUniversalCoords(target); 34 | } else { 35 | InvisibleTrapDoor.randomAloneSpot(world, rat); 36 | target = rat.getUniversalCoords(); 37 | } 38 | } 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/HighScore.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics2D; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class HighScore { 9 | private final List scores = new ArrayList(); 10 | 11 | public void add(Score score) { 12 | this.scores.add(score); 13 | } 14 | 15 | public void draw(Graphics2D g2d, int width, int height) { 16 | g2d.setColor(Color.WHITE); 17 | int h = g2d.getFontMetrics().getHeight(); 18 | int y = 0; 19 | long sum = 0; 20 | long maxSum = -1; 21 | long maxScore = -1; 22 | long maxTime = -1; 23 | for (Score score : scores) { 24 | y += 1; 25 | sum += score.getScore(); 26 | g2d.drawString(score.toTString("" + y), 10, (2 * y) * h); 27 | maxSum = Math.max(maxSum, score.getTscore()); 28 | maxScore = Math.max(maxScore, score.getScore()); 29 | maxTime = Math.max(maxTime, score.getTime()); 30 | } 31 | y++; 32 | g2d.drawString("final: " + sum + "/" + maxSum, 10, (2 * y) * h); 33 | y++; 34 | g2d.drawString("at : " + maxTime / 1000 / 60 + "minutes", 10, (2 * y) * h); 35 | y++; 36 | g2d.drawString("and with most individual socre : " + maxScore, 10, (2 * y) * h); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Mushroom.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | 10 | //will swap you with other rat if possible 11 | public class Mushroom implements Item { 12 | 13 | private static final float maxSize = 20; 14 | int anim = seed.nextInt(10); 15 | private int size = seed.nextInt(((int) maxSize - 10)) + 10; 16 | 17 | public Color getMinimapColor() { 18 | return Color.CYAN; 19 | } 20 | 21 | @Override 22 | public void playMainSoundFor(SoundsBuffer rat) { 23 | rat.addToEatQueue(SoundsBuffer.piskLong); 24 | } 25 | 26 | 27 | @Override 28 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 29 | if (level == 3) { 30 | int finalSize = (int) ((float) size / maxSize * (float) zoom); 31 | anim++; 32 | if (anim > 21) { 33 | anim = 0; 34 | } 35 | g2d.drawImage(SpritesProvider.getMushroom(((anim / 3) % 4)), coordx + (zoom - finalSize) / 2, coordy + (zoom - finalSize) / 2, finalSize, finalSize, null); 36 | } 37 | } 38 | 39 | @Override 40 | public void drawThumbnail(Graphics2D g2d, int size) { 41 | drawInto(g2d, 0, 0, size, 3, null, 0, 0); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/ColorfullFlask.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | 10 | 11 | //will change the sprite of rat 12 | public class ColorfullFlask implements Item { 13 | 14 | 15 | private static final float maxSize = 20; 16 | int anim = seed.nextInt(10); 17 | private int size = seed.nextInt(((int) (maxSize / 4))) + (int) (maxSize / 2); 18 | 19 | public Color getMinimapColor() { 20 | return Color.CYAN; 21 | } 22 | 23 | @Override 24 | public void playMainSoundFor(SoundsBuffer rat) { 25 | rat.addToEatQueue(SoundsBuffer.piskLong); 26 | } 27 | 28 | 29 | @Override 30 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 31 | if (level == 2) { 32 | int finalSize = (int) ((float) size / maxSize * (float) zoom); 33 | anim++; 34 | if (anim > 21) { 35 | anim = 0; 36 | } 37 | g2d.drawImage(SpritesProvider.flask[((anim / 3) % 3)], coordx + (zoom - finalSize) / 2, coordy + (zoom - finalSize) / 2, finalSize, finalSize, null); 38 | } 39 | } 40 | 41 | @Override 42 | public void drawThumbnail(Graphics2D g2d, int size) { 43 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/KeyboardControl2.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.event.KeyEvent; 7 | 8 | public class KeyboardControl2 extends KeyboardControl { 9 | 10 | @Override 11 | public String id() { 12 | return "k2"; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "wasd 13 2456"; 18 | } 19 | 20 | public void act(Rat rat, KeyEvent e, World world) { 21 | if (e.getKeyCode() == KeyEvent.VK_A) { 22 | rat.setMouseLeft(world); 23 | } else if (e.getKeyCode() == KeyEvent.VK_W) { 24 | rat.setMouseUp(world); 25 | } else if (e.getKeyCode() == KeyEvent.VK_D) { 26 | rat.setMouseRight(world); 27 | } else if (e.getKeyCode() == KeyEvent.VK_S) { 28 | rat.setMouseDown(world); 29 | } else if (e.getKeyChar() == '1') { 30 | zoomIn(); 31 | } else if (e.getKeyChar() == '3') { 32 | zoomOut(); 33 | } else if (e.getKeyChar() == '2') { 34 | //we actually need two maps - anymated and non anymated.. 35 | map = !map; 36 | } else if ((e.getKeyChar() == '4')) { 37 | world.regenerateAll(); 38 | } 39 | //keep those two? Made it controllable? 40 | else if ((e.getKeyChar() == '5')) { 41 | world.allRatsSpread(true); 42 | } else if ((e.getKeyChar() == '6')) { 43 | world.allRatsSpread(false); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/traps: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.Water": 0, 4 | "class nonsense.hamsterrun.env.traps.OneWayTeleport": 0, 5 | "class nonsense.hamsterrun.env.traps.Torturer": 20, 6 | "class nonsense.hamsterrun.env.traps.Tunnel": 0, 7 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 0, 8 | "class nonsense.hamsterrun.env.traps.AllWayTeleport": 0, 9 | "class nonsense.hamsterrun.env.traps.Fire": 0 10 | }, 11 | "aliensWithProbabilityOverride": { 12 | "class nonsense.hamsterrun.env.aliens.BigBats": 0, 13 | "class nonsense.hamsterrun.env.aliens.Boulder": 50, 14 | "class nonsense.hamsterrun.env.aliens.Key": 10, 15 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 0, 16 | "class nonsense.hamsterrun.env.aliens.Cat": 0, 17 | "class nonsense.hamsterrun.env.aliens.SmallBats": 0, 18 | "class nonsense.hamsterrun.env.aliens.Ghost": 1, 19 | "class nonsense.hamsterrun.env.aliens.BigFlies": 0, 20 | "class nonsense.hamsterrun.env.aliens.Hawk": 0 21 | }, 22 | "baseSize": 10, 23 | "baseDensityMin": 1, 24 | "baseDensityMax": 2, 25 | "gridSize": 3, 26 | "gridConnectivityMin": 1, 27 | "gridConnectivityMax": 1, 28 | "delayMs": 50, 29 | "keepRegenerating": true, 30 | "regSpeed": 200, 31 | "columns": 2, 32 | "maxAliens": 20, 33 | "tunnelConfusion": 20, 34 | "mouseSensitivity": 200, 35 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 36 | "cumulativeMinimalNUmberOfKeys": 10, 37 | "individualMinimalScoreToEnterGoldenGate": 2000, 38 | "floor": "floor" 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/KeyboardControl3.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.event.KeyEvent; 7 | 8 | public class KeyboardControl3 extends KeyboardControl { 9 | 10 | @Override 11 | public String id() { 12 | return "k3"; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "jilk 89 0 bckspace -="; 18 | } 19 | 20 | public void act(Rat rat, KeyEvent e, World world) { 21 | if (e.getKeyCode() == KeyEvent.VK_J) { 22 | rat.setMouseLeft(world); 23 | } else if (e.getKeyCode() == KeyEvent.VK_I) { 24 | rat.setMouseUp(world); 25 | } else if (e.getKeyCode() == KeyEvent.VK_L) { 26 | rat.setMouseRight(world); 27 | } else if (e.getKeyCode() == KeyEvent.VK_K) { 28 | rat.setMouseDown(world); 29 | } else if (e.getKeyChar() == '8') { 30 | zoomIn(); 31 | } else if (e.getKeyChar() == '9') { 32 | zoomOut(); 33 | } else if (e.getKeyChar() == '0') { 34 | //we actually need two maps - anymated and non anymated.. 35 | map = !map; 36 | } else if ((e.getKeyCode() == KeyEvent.VK_BACK_SPACE)) { 37 | world.regenerateAll(); 38 | } 39 | //keep those two? Made it configurable? 40 | //yes! per player? Yes! 41 | else if ((e.getKeyChar() == '-')) { 42 | world.allRatsSpread(true); 43 | } else if ((e.getKeyChar() == '=')) { 44 | world.allRatsSpread(false); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/hunt: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.Water": 3, 4 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 4, 5 | "class nonsense.hamsterrun.env.traps.Salat": 5, 6 | "class nonsense.hamsterrun.env.traps.Torturer": 0, 7 | "class nonsense.hamsterrun.env.traps.Fire": 0, 8 | "class nonsense.hamsterrun.env.traps.TrapDoor": 4, 9 | "class nonsense.hamsterrun.env.traps.Grass": 0, 10 | "class nonsense.hamsterrun.env.traps.Pepper": 15, 11 | "class nonsense.hamsterrun.env.traps.Repa": 5 12 | }, 13 | "aliensWithProbabilityOverride": { 14 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 0, 15 | "class nonsense.hamsterrun.env.aliens.Cat": 75, 16 | "class nonsense.hamsterrun.env.aliens.Boulder": 0, 17 | "class nonsense.hamsterrun.env.aliens.Key": 25, 18 | "class nonsense.hamsterrun.env.aliens.BigFlies": 0, 19 | "class nonsense.hamsterrun.env.aliens.BigBats": 0, 20 | "class nonsense.hamsterrun.env.aliens.Hawk": 0, 21 | "class nonsense.hamsterrun.env.aliens.SmallBats": 0, 22 | "class nonsense.hamsterrun.env.aliens.Ghost": 1 23 | }, 24 | "baseSize": 10, 25 | "baseDensityMin": 1, 26 | "baseDensityMax": 2, 27 | "gridSize": 3, 28 | "gridConnectivityMin": 1, 29 | "gridConnectivityMax": 1, 30 | "delayMs": 50, 31 | "keepRegenerating": true, 32 | "regSpeed": 200, 33 | "columns": 2, 34 | "maxAliens": 10, 35 | "tunnelConfusion": 20, 36 | "mouseSensitivity": 200, 37 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 38 | "cumulativeMinimalNUmberOfKeys": 10, 39 | "individualMinimalScoreToEnterGoldenGate": 2000, 40 | "floor": "floor" 41 | } -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/ComputerControl2.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.env.traps.Fire; 7 | import nonsense.hamsterrun.env.traps.Torturer; 8 | import nonsense.hamsterrun.env.traps.Vegetable; 9 | import nonsense.hamsterrun.env.traps.Water; 10 | 11 | public class ComputerControl2 extends ComputerControl { 12 | 13 | @Override 14 | public String id() { 15 | return "pc2"; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "chaos around 5 is really chaotic, above 50 is really appatic"; 21 | } 22 | 23 | public void selfAct(Rat rat, World world) { 24 | if (world.getBlockField(rat.getUniversalCoords()).getItem() instanceof Vegetable) { 25 | rat.setAction(RatActions.EAT); 26 | } else if (rat.getAction().isInterruptible()) { 27 | rat.setAction(RatActions.WALK); 28 | } 29 | if (world.getBlockField(rat.getUniversalCoords()).getItem() instanceof Fire) { 30 | rat.setSpeed(rat.getSpeed() + 3); 31 | } 32 | if (world.getBlockField(rat.getUniversalCoords()).getItem() instanceof Water) { 33 | rat.setSpeed(10); 34 | } 35 | if (world.getBlockField(rat.getUniversalCoords()).getItem() instanceof Torturer) { 36 | rat.setSpeed(1); 37 | } else { 38 | if (RatsController.seed.nextInt(3) == 0) { 39 | rat.setSpeed(RatsController.seed.nextInt(3) + 1); 40 | } 41 | } 42 | niceMove(rat, world, chaos); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/waterworld: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.AllWayTeleport": 0, 4 | "class nonsense.hamsterrun.env.traps.Water": 100, 5 | "class nonsense.hamsterrun.env.traps.Cage": 5, 6 | "class nonsense.hamsterrun.env.traps.Tunnel": 10, 7 | "class nonsense.hamsterrun.env.traps.Torturer": 0, 8 | "class nonsense.hamsterrun.env.traps.Repa": 0, 9 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 0, 10 | "class nonsense.hamsterrun.env.traps.TrapDoor": 4, 11 | "class nonsense.hamsterrun.env.traps.Salat": 0, 12 | "class nonsense.hamsterrun.env.traps.OneWayTeleport": 0 13 | }, 14 | "aliensWithProbabilityOverride": { 15 | "class nonsense.hamsterrun.env.aliens.Boulder": 0, 16 | "class nonsense.hamsterrun.env.aliens.Hawk": 1, 17 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 0, 18 | "class nonsense.hamsterrun.env.aliens.SmallBats": 20, 19 | "class nonsense.hamsterrun.env.aliens.BigFlies": 0, 20 | "class nonsense.hamsterrun.env.aliens.Ghost": 0, 21 | "class nonsense.hamsterrun.env.aliens.Cat": 1, 22 | "class nonsense.hamsterrun.env.aliens.Key": 25 23 | }, 24 | "baseSize": 10, 25 | "baseDensityMin": 1, 26 | "baseDensityMax": 2, 27 | "gridSize": 3, 28 | "gridConnectivityMin": 1, 29 | "gridConnectivityMax": 1, 30 | "delayMs": 50, 31 | "keepRegenerating": true, 32 | "regSpeed": 200, 33 | "columns": 2, 34 | "maxAliens": 10, 35 | "tunnelConfusion": 20, 36 | "mouseSensitivity": 200, 37 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 38 | "cumulativeMinimalNUmberOfKeys": 10, 39 | "individualMinimalScoreToEnterGoldenGate": 2000, 40 | "floor": "floor" 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/nonsense/hamsterrun/BaseConfigTest.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | public class BaseConfigTest { 7 | 8 | 9 | public static BaseConfigTest baseConfig = new BaseConfigTest(); 10 | 11 | 12 | @Test 13 | public void getDensityTest() { 14 | BaseConfig config = new BaseConfig(); 15 | for (int x = 0; x < 1000; x++) { 16 | int d = config.getDensity(); 17 | Assertions.assertTrue(d >= config.getBaseDensityMin()); 18 | Assertions.assertTrue(d <= config.getBaseDensityMax()); 19 | } 20 | config.setBaseDensityMin(2); 21 | config.setBaseDensityMax(2); 22 | for (int x = 0; x < 1000; x++) { 23 | int d = config.getDensity(); 24 | Assertions.assertEquals(2, d); 25 | } 26 | } 27 | 28 | @Test 29 | public void getConnectivityTest() { 30 | BaseConfig config = new BaseConfig(); 31 | for (int x = 0; x < 1000; x++) { 32 | int d = config.getConnectivity(); 33 | Assertions.assertTrue(d >= config.getGridConnectivityMin()); 34 | Assertions.assertTrue(d <= config.getGridConnectivityMax()); 35 | } 36 | config.setGridConnectivityMin(2); 37 | config.setGridConnectivityMax(2); 38 | for (int x = 0; x < 1000; x++) { 39 | int d = config.getConnectivity(); 40 | Assertions.assertEquals(2, d); 41 | } 42 | } 43 | 44 | @Test 45 | public void getTrapByNameTest() throws ClassNotFoundException { 46 | Class clazz = BaseConfig.getTrapClassByName("Item"); 47 | Assertions.assertNotNull(clazz); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/KeyboardControl1.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.event.KeyEvent; 7 | 8 | public class KeyboardControl1 extends KeyboardControl { 9 | 10 | @Override 11 | public String id() { 12 | return "k1"; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "<- ^ -> + - end, del, home, ins"; 18 | } 19 | 20 | public void act(Rat rat, KeyEvent e, World world) { 21 | if (e.getKeyCode() == KeyEvent.VK_LEFT) { 22 | rat.setMouseLeft(world); 23 | } else if (e.getKeyCode() == KeyEvent.VK_UP) { 24 | rat.setMouseUp(world); 25 | } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { 26 | rat.setMouseRight(world); 27 | } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { 28 | rat.setMouseDown(world); 29 | } else if (e.getKeyChar() == '+') { 30 | zoomIn(); 31 | } else if (e.getKeyChar() == '-') { 32 | zoomOut(); 33 | } else if (e.getKeyCode() == KeyEvent.VK_END) { 34 | //we actually need two maps - anymated and non anymated.. what to do with zoom? 35 | //base second zoom here internally? 36 | map = !map; 37 | } else if (e.getKeyCode() == KeyEvent.VK_DELETE) { 38 | world.regenerateAll(); 39 | } 40 | //keep those two? Made it configurable? 41 | //yes! per player? Yes! 42 | else if (e.getKeyCode() == KeyEvent.VK_HOME) { 43 | world.allRatsSpread(true); 44 | } else if (e.getKeyCode() == KeyEvent.VK_INSERT) { 45 | world.allRatsSpread(false); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Vegetable.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.Rat; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | 8 | import java.awt.Color; 9 | import java.awt.Graphics2D; 10 | import java.awt.Image; 11 | 12 | public abstract class Vegetable implements Item { 13 | 14 | private float maxEnergy = getMaxEnergy(); 15 | int energy = getStartEnergy(); 16 | 17 | protected float getMaxEnergy() { 18 | return 10; 19 | } 20 | 21 | protected int getStartEnergy() { 22 | return seed.nextInt(((int) maxEnergy - 2)) + 2; 23 | } 24 | 25 | public Color getMinimapColor() { 26 | return Color.green; 27 | } 28 | 29 | @Override 30 | public void playMainSoundFor(SoundsBuffer rat) { 31 | rat.addToEatQueue(SoundsBuffer.eat); 32 | } 33 | 34 | 35 | @Override 36 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 37 | if (level == targetLevel()) { 38 | int finalSize = (int) ((float) energy / maxEnergy * (float) zoom); 39 | g2d.drawImage(getSprite(), coordx + (zoom - finalSize) / 2, coordy + (zoom - finalSize) / 2, finalSize, finalSize, null); 40 | } 41 | } 42 | 43 | protected int targetLevel() { 44 | return 2; 45 | } 46 | 47 | @Override 48 | public void drawThumbnail(Graphics2D g2d, int size) { 49 | drawInto(g2d, 0, 0, size, targetLevel(), null, 0, 0); 50 | } 51 | 52 | protected abstract Image getSprite(); 53 | 54 | abstract public int eat(Rat eater, World world); 55 | 56 | public boolean eaten() { 57 | return (energy <= 0); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Cage.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | import java.awt.Image; 10 | 11 | //can be reached only once collected keys > number of rats * constant is reached. 12 | //once reached, rats win 13 | //hhmhm all rats must enter in limited time? Score? 14 | public class Cage implements Item { 15 | 16 | int anim = seed.nextInt(10); 17 | 18 | public Color getMinimapColor() { 19 | return Color.orange; 20 | } 21 | 22 | @Override 23 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 24 | if (level == 2) { 25 | g2d.drawImage(SpritesProvider.gate, coordx, coordy, zoom, zoom, null); 26 | } 27 | } 28 | 29 | @Override 30 | public void drawMapHighlight(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 31 | if (level == 3) { 32 | anim++; 33 | if (anim > 10) { 34 | anim = 0; 35 | } 36 | g2d.setColor(Color.yellow); 37 | g2d.drawOval(coordx - anim, coordy - anim, zoom + 2 * anim, zoom + 2 * +anim); 38 | } 39 | } 40 | 41 | protected Image getSprite() { 42 | return SpritesProvider.gate; 43 | } 44 | 45 | @Override 46 | public void drawThumbnail(Graphics2D g2d, int size) { 47 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 48 | } 49 | 50 | @Override 51 | public void playMainSoundFor(SoundsBuffer rat) { 52 | rat.addToMoveQueue(SoundsBuffer.piskLong); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/AllWayTeleport.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.env.Rat; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Point; 9 | import java.awt.image.BufferedImage; 10 | import java.util.ArrayList; 11 | import java.util.Collections; 12 | import java.util.List; 13 | 14 | public class AllWayTeleport extends Teleport { 15 | //will drop the mouse to any other gate. 16 | //it MUST drop it NEXT to it, otherwise it will cause endless loop 17 | //Not sure what to do if there are no other gates - it will msot likely drop itself nexto itself, which would be nicely confusing 18 | 19 | 20 | @Override 21 | protected BufferedImage getSprite(int id) { 22 | return SpritesProvider.getAllWayTeleport(id); 23 | } 24 | 25 | @Override 26 | public void relocate(World world, Rat rat) { 27 | List twoWayTeleports = new ArrayList<>(); 28 | for (int x = 0; x < BaseConfig.getConfig().getGridSize() * BaseConfig.getConfig().getBaseSize(); x++) { 29 | for (int y = 0; y < BaseConfig.getConfig().getGridSize() * BaseConfig.getConfig().getBaseSize(); y++) { 30 | Item item = world.getBlockField(new Point(x, y)).getItem(); 31 | if (item instanceof AllWayTeleport) { 32 | System.out.println("Found teleport at " + x + ":" + y + "; rat is at " + rat.getUniversalCoords()); 33 | twoWayTeleports.add(new Point(x, y)); 34 | } 35 | } 36 | } 37 | if (twoWayTeleports.isEmpty()) { 38 | System.out.println("No destination!"); 39 | return; 40 | } 41 | Collections.shuffle(twoWayTeleports); 42 | Point w = twoWayTeleports.get(0); 43 | moveRatTo(world, rat, w); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Water.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | 10 | 11 | //will sloww down rapidly. blue transaprent ove rat 12 | //wave effect - would be nice if it is slihtly over field, and there willbe /\/\/\/\ which will match form l->r and from down->up 13 | public class Water implements Item { 14 | 15 | public static int anim = 0; //indeed all watters must share anim counter! 16 | private static Thread waterCounter = new Thread("water waiver") { 17 | @Override 18 | public void run() { 19 | while (true) { 20 | try { 21 | Thread.sleep(500); 22 | anim++; 23 | if (anim > 1) { 24 | anim = 0; 25 | } 26 | } catch (Exception ex) { 27 | ex.printStackTrace(); 28 | } 29 | } 30 | } 31 | }; 32 | 33 | static { 34 | waterCounter.setDaemon(true); 35 | waterCounter.start(); 36 | } 37 | 38 | 39 | public Color getMinimapColor() { 40 | return Color.blue; 41 | } 42 | 43 | @Override 44 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 45 | if (level == 3) { 46 | g2d.drawImage(SpritesProvider.water[anim % 2], coordx - zoom / 2, coordy - zoom / 2, 2 * zoom, 2 * zoom, null); 47 | } 48 | } 49 | 50 | @Override 51 | public void drawThumbnail(Graphics2D g2d, int size) { 52 | drawInto(g2d, 0, 0, size, 3, null, 0, 0); 53 | } 54 | 55 | @Override 56 | public void playMainSoundFor(SoundsBuffer rat) { 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/HumanControl.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | public abstract class HumanControl implements RatsController.RatControl { 7 | protected boolean map = false; 8 | private int worldZoom = 64; 9 | private int mapZoom = 16; 10 | private boolean display = false; 11 | 12 | private static int calcZoomIn(int i) { 13 | return i + Math.max(i / 2, 1); 14 | } 15 | 16 | private static int calcZoomOut(int i) { 17 | i = i - Math.max(1, i / 2); 18 | if (i <= 0) { 19 | i = 1; 20 | } 21 | return i; 22 | } 23 | 24 | @Override 25 | public int getZoom() { 26 | if (getMap() == 0) { 27 | return worldZoom; 28 | } else { 29 | return mapZoom; 30 | } 31 | } 32 | 33 | @Override 34 | public void zoomIn() { 35 | if (getMap() == 0) { 36 | worldZoom = calcZoomIn(worldZoom); 37 | } else { 38 | mapZoom = calcZoomIn(mapZoom); 39 | } 40 | } 41 | 42 | @Override 43 | public void zoomOut() { 44 | if (getMap() == 0) { 45 | worldZoom = calcZoomOut(worldZoom); 46 | } else { 47 | mapZoom = calcZoomOut(mapZoom); 48 | } 49 | } 50 | 51 | @Override 52 | public void selfAct(Rat rat, World world) { 53 | 54 | } 55 | 56 | @Override 57 | public boolean isDisplay() { 58 | return display; 59 | } 60 | 61 | @Override 62 | public void setDisplay(Boolean aBoolean) { 63 | this.display = aBoolean; 64 | } 65 | 66 | @Override 67 | public void setChaos(int i) { 68 | 69 | } 70 | 71 | @Override 72 | public int getMap() { 73 | if (map) { 74 | return 1; 75 | } else { 76 | return 0; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/fireworld: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.Torturer": 0, 4 | "class nonsense.hamsterrun.env.traps.Pepper": 0, 5 | "class nonsense.hamsterrun.env.traps.Salat": 10, 6 | "class nonsense.hamsterrun.env.traps.Fire": 50, 7 | "class nonsense.hamsterrun.env.traps.Repa": 0, 8 | "class nonsense.hamsterrun.env.traps.ColorfullFlask": 0, 9 | "class nonsense.hamsterrun.env.traps.Carrot": 0, 10 | "class nonsense.hamsterrun.env.traps.Mushroom": 0, 11 | "class nonsense.hamsterrun.env.traps.OneWayTeleport": 2, 12 | "class nonsense.hamsterrun.env.traps.Tunnel": 0, 13 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 2, 14 | "class nonsense.hamsterrun.env.traps.AllWayTeleport": 2, 15 | "class nonsense.hamsterrun.env.traps.Grass": 10, 16 | "class nonsense.hamsterrun.env.traps.Water": 0 17 | }, 18 | "aliensWithProbabilityOverride": { 19 | "class nonsense.hamsterrun.env.aliens.BigFlies": 8, 20 | "class nonsense.hamsterrun.env.aliens.Ghost": 1, 21 | "class nonsense.hamsterrun.env.aliens.Cat": 0, 22 | "class nonsense.hamsterrun.env.aliens.SmallBats": 4, 23 | "class nonsense.hamsterrun.env.aliens.Key": 6, 24 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 8, 25 | "class nonsense.hamsterrun.env.aliens.Hawk": 0, 26 | "class nonsense.hamsterrun.env.aliens.Boulder": 0, 27 | "class nonsense.hamsterrun.env.aliens.BigBats": 4 28 | }, 29 | "baseSize": 10, 30 | "baseDensityMin": 1, 31 | "baseDensityMax": 2, 32 | "gridSize": 3, 33 | "gridConnectivityMin": 1, 34 | "gridConnectivityMax": 1, 35 | "delayMs": 50, 36 | "keepRegenerating": true, 37 | "regSpeed": 200, 38 | "columns": 2, 39 | "maxAliens": 6, 40 | "tunnelConfusion": 20, 41 | "mouseSensitivity": 200, 42 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 43 | "cumulativeMinimalNUmberOfKeys": 10, 44 | "individualMinimalScoreToEnterGoldenGate": 2000, 45 | "floor": "fire" 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/nonsense/hamsterrun/env/GifToImagesTest.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import nonsense.hamsterrun.sprites.GifToImages; 4 | import nonsense.hamsterrun.sprites.SpritesProvider; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | import org.w3c.dom.NamedNodeMap; 8 | import org.w3c.dom.Node; 9 | import org.w3c.dom.NodeList; 10 | 11 | import javax.imageio.ImageIO; 12 | import javax.imageio.ImageReader; 13 | import javax.imageio.metadata.IIOMetadata; 14 | import javax.imageio.stream.ImageInputStream; 15 | import java.awt.image.BufferedImage; 16 | import java.io.IOException; 17 | import java.net.URL; 18 | import java.util.ArrayList; 19 | import java.util.HashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | public class GifToImagesTest { 24 | 25 | @Test 26 | public void decodeTest1() throws IOException { 27 | URL fallUrl = SpritesProvider.class.getClassLoader().getResource("nonsense/hamsterrun/sprites/aliens/boulder.gif"); 28 | List r = GifToImages.decode(fallUrl); 29 | Assertions.assertEquals(2, r.size()); 30 | for (BufferedImage img: r){ 31 | Assertions.assertEquals(img.getWidth(),200); 32 | Assertions.assertEquals(img.getHeight(),200); 33 | } 34 | for (int i=1; i < r.size(); i++){ 35 | Assertions.assertNotEquals(r.get(i-1), r.get(i)); 36 | } 37 | } 38 | 39 | @Test 40 | public void decodeTest2() throws IOException { 41 | URL fallUrl = SpritesProvider.class.getClassLoader().getResource("nonsense/hamsterrun/sprites/aliens/bigBats.gif"); 42 | List r = GifToImages.decode(fallUrl); 43 | Assertions.assertEquals(50, r.size()); 44 | for (BufferedImage img: r){ 45 | Assertions.assertEquals(img.getWidth(),800); 46 | Assertions.assertEquals(img.getHeight(),800); 47 | } 48 | for (int i=1; i < r.size(); i++){ 49 | Assertions.assertNotEquals(r.get(i-1), r.get(i)); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/paradise: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.Pepper": 1, 4 | "class nonsense.hamsterrun.env.traps.Salat": 2, 5 | "class nonsense.hamsterrun.env.traps.Torturer": 0, 6 | "class nonsense.hamsterrun.env.traps.Fire": 0, 7 | "class nonsense.hamsterrun.env.traps.AllWayTeleport": 0, 8 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 1, 9 | "class nonsense.hamsterrun.env.traps.Mushroom": 0, 10 | "class nonsense.hamsterrun.env.traps.OneWayTeleport": 0, 11 | "class nonsense.hamsterrun.env.traps.InvisibleTrapDoor": 2, 12 | "class nonsense.hamsterrun.env.traps.Carrot": 1, 13 | "class nonsense.hamsterrun.env.traps.ColorfullFlask": 0, 14 | "class nonsense.hamsterrun.env.traps.Repa": 1, 15 | "class nonsense.hamsterrun.env.traps.TrapDoor": 3, 16 | "class nonsense.hamsterrun.env.traps.Tunnel": 5, 17 | "class nonsense.hamsterrun.env.traps.Water": 0 18 | }, 19 | "aliensWithProbabilityOverride": { 20 | "class nonsense.hamsterrun.env.aliens.Boulder": 0, 21 | "class nonsense.hamsterrun.env.aliens.BigFlies": 0, 22 | "class nonsense.hamsterrun.env.aliens.SmallBats": 0, 23 | "class nonsense.hamsterrun.env.aliens.BigBats": 0, 24 | "class nonsense.hamsterrun.env.aliens.Cat": 0, 25 | "class nonsense.hamsterrun.env.aliens.Key": 1, 26 | "class nonsense.hamsterrun.env.aliens.Hawk": 0, 27 | "class nonsense.hamsterrun.env.aliens.Ghost": 0, 28 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 0 29 | }, 30 | "baseSize": 10, 31 | "baseDensityMin": 1, 32 | "baseDensityMax": 2, 33 | "gridSize": 3, 34 | "gridConnectivityMin": 1, 35 | "gridConnectivityMax": 1, 36 | "delayMs": 50, 37 | "keepRegenerating": true, 38 | "regSpeed": 200, 39 | "columns": 2, 40 | "maxAliens": 1, 41 | "tunnelConfusion": 20, 42 | "mouseSensitivity": 200, 43 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 44 | "cumulativeMinimalNUmberOfKeys": 10, 45 | "individualMinimalScoreToEnterGoldenGate": 2000, 46 | "floor": "floor" 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/InvisibleTrapDoor.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.Rat; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | 8 | import java.awt.Color; 9 | import java.awt.Graphics2D; 10 | 11 | public class InvisibleTrapDoor implements Item, Relocator { 12 | // will always lead to random space 13 | 14 | protected boolean closed = true; 15 | 16 | public static void randomAloneSpot(World world, Rat rat) { 17 | world.teleportMouse(rat, false, true); 18 | } 19 | 20 | public Color getMinimapColor() { 21 | return new Color(200, 200, 200); 22 | } 23 | 24 | @Override 25 | public void playMainSoundFor(SoundsBuffer rat) { 26 | rat.addToMoveQueue(SoundsBuffer.brbliFall); 27 | } 28 | 29 | 30 | @Override 31 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 32 | if (level == 2) { 33 | g2d.setColor(new Color(20, 20, 20)); 34 | if (closed) { 35 | g2d.drawLine(coordx + zoom / 4, coordy + zoom / 4, coordx + zoom - zoom / 4, coordy + zoom - zoom / 4); 36 | g2d.drawLine(coordx + zoom / 4, coordy + zoom - zoom / 4, coordx + zoom - zoom / 4, coordy + zoom / 4); 37 | //g2d.drawLine(coordx, coordy + zoom, coordx + zoom, coordy); 38 | } else { 39 | g2d.fillRect(coordx + zoom / 4, coordy + zoom / 4, zoom - zoom / 2, zoom - zoom / 2); 40 | } 41 | } 42 | } 43 | 44 | @Override 45 | public void drawThumbnail(Graphics2D g2d, int size) { 46 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 47 | } 48 | 49 | public void close() { 50 | this.closed = true; 51 | } 52 | 53 | public void open() { 54 | this.closed = false; 55 | } 56 | 57 | @Override 58 | public void relocate(World world, Rat rat) { 59 | randomAloneSpot(world, rat); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/BigBats.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | //moving chaotically aka ai mouse 12 | //must be faster then rats... maybe different thread then repl? Maybe special % in repl? 13 | public class BigBats extends MovingOne { 14 | 15 | protected int chaos = seed.nextInt(5) + 10; 16 | protected boolean moving = false; 17 | 18 | public BigBats() { 19 | this.speed = seed.nextInt(2) + 2; 20 | this.anim = new AnimationCounrer(1000); 21 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 22 | } 23 | 24 | @Override 25 | protected boolean returnOnSalat(World world) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean selfAct(World world) { 31 | this.action = RatActions.WALK; 32 | ComputerControl.dummyMove(this, world, chaos); 33 | if (isMoving()) { 34 | move(world); 35 | } 36 | anim.addLimited(); 37 | return true; 38 | } 39 | 40 | private boolean isMoving() { 41 | if (seed.nextInt(chaos) == 0) { 42 | moving = !moving; 43 | } 44 | return moving; 45 | } 46 | 47 | @Override 48 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 49 | 50 | } 51 | 52 | 53 | @Override 54 | protected String getSkin() { 55 | return "bigBats"; 56 | } 57 | 58 | @Override 59 | public void interact(Rat rat, World world) { 60 | playMainSoundFor(rat.getSounds()); 61 | rat.adjustScore(-50); 62 | } 63 | 64 | @Override 65 | public void playMainSoundFor(SoundsBuffer rat) { 66 | rat.addToHarmQueue(SoundsBuffer.piskMuch); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/resources/nonsense/hamsterrun/preconf/hawk: -------------------------------------------------------------------------------- 1 | { 2 | "itemsWithProbabilityOverride": { 3 | "class nonsense.hamsterrun.env.traps.Water": 0, 4 | "class nonsense.hamsterrun.env.traps.TrapDoor": 4, 5 | "class nonsense.hamsterrun.env.traps.Pepper": 0, 6 | "class nonsense.hamsterrun.env.traps.Carrot": 0, 7 | "class nonsense.hamsterrun.env.traps.Fire": 0, 8 | "class nonsense.hamsterrun.env.traps.Mushroom": 0, 9 | "class nonsense.hamsterrun.env.traps.Cage": 10, 10 | "class nonsense.hamsterrun.env.traps.Salat": 20, 11 | "class nonsense.hamsterrun.env.traps.AllWayTeleport": 8, 12 | "class nonsense.hamsterrun.env.traps.Cucumber": 40, 13 | "class nonsense.hamsterrun.env.traps.Tunnel": 50, 14 | "class nonsense.hamsterrun.env.traps.TwoWayTeleport": 0, 15 | "class nonsense.hamsterrun.env.traps.Repa": 0, 16 | "class nonsense.hamsterrun.env.traps.Torturer": 0, 17 | "class nonsense.hamsterrun.env.traps.ColorfullFlask": 0, 18 | "class nonsense.hamsterrun.env.traps.OneWayTeleport": 0 19 | }, 20 | "aliensWithProbabilityOverride": { 21 | "class nonsense.hamsterrun.env.aliens.Boulder": 2, 22 | "class nonsense.hamsterrun.env.aliens.BigFlies": 2, 23 | "class nonsense.hamsterrun.env.aliens.Cat": 0, 24 | "class nonsense.hamsterrun.env.aliens.SmallBats": 2, 25 | "class nonsense.hamsterrun.env.aliens.Hawk": 20, 26 | "class nonsense.hamsterrun.env.aliens.SmallFlies": 2, 27 | "class nonsense.hamsterrun.env.aliens.BigBats": 2, 28 | "class nonsense.hamsterrun.env.aliens.Key": 10, 29 | "class nonsense.hamsterrun.env.aliens.Ghost": 1 30 | }, 31 | "baseSize": 10, 32 | "baseDensityMin": 1, 33 | "baseDensityMax": 2, 34 | "gridSize": 3, 35 | "gridConnectivityMin": 1, 36 | "gridConnectivityMax": 1, 37 | "delayMs": 50, 38 | "keepRegenerating": true, 39 | "regSpeed": 200, 40 | "columns": 2, 41 | "maxAliens": 6, 42 | "tunnelConfusion": 20, 43 | "mouseSensitivity": 200, 44 | "cumulativeMinimalScoreToEnterGoldenGate": 20000, 45 | "cumulativeMinimalNUmberOfKeys": 10, 46 | "individualMinimalScoreToEnterGoldenGate": 2000, 47 | "floor": "floor" 48 | } -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/SmallBats.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | //moving chaotically aka ai mouse 12 | //must be faster then rats... maybe different thread then repl? Maybe special % in repl? 13 | public class SmallBats extends MovingOne { 14 | 15 | protected int chaos = seed.nextInt(30) + 10; 16 | protected boolean moving = false; 17 | 18 | public SmallBats() { 19 | this.speed = seed.nextInt(4) + 3; 20 | this.anim = new AnimationCounrer(1000); 21 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 22 | } 23 | 24 | @Override 25 | protected boolean returnOnSalat(World world) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean selfAct(World world) { 31 | this.action = RatActions.WALK; 32 | ComputerControl.dummyMove(this, world, chaos); 33 | if (isMoving()) { 34 | move(world); 35 | } 36 | anim.addLimited(); 37 | return true; 38 | } 39 | 40 | private boolean isMoving() { 41 | if (seed.nextInt(chaos) == 0) { 42 | moving = !moving; 43 | } 44 | return moving; 45 | } 46 | 47 | @Override 48 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 49 | 50 | } 51 | 52 | 53 | @Override 54 | protected String getSkin() { 55 | return "smallBats"; 56 | } 57 | 58 | @Override 59 | public void interact(Rat rat, World world) { 60 | playMainSoundFor(rat.getSounds()); 61 | rat.adjustScore(-10); 62 | } 63 | 64 | @Override 65 | public void playMainSoundFor(SoundsBuffer rat) { 66 | rat.addToHarmQueue(SoundsBuffer.piskMuch); 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Torturer.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.Color; 8 | import java.awt.Graphics2D; 9 | import java.awt.image.BufferedImage; 10 | 11 | //most ikely more shapes as in trapdoor 12 | public class Torturer implements Item { 13 | //will remove energy on passing through 14 | // will remove more when speed is high 15 | 16 | int anim = seed.nextInt(20); 17 | 18 | public Color getMinimapColor() { 19 | return Color.red; 20 | } 21 | 22 | @Override 23 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int xx, int yy) { 24 | if (level == 2) { 25 | anim++; 26 | if (anim > 20) { 27 | anim = 0; 28 | } 29 | } 30 | double dz = (double) zoom; 31 | for (double x = 0.0; x < 1; x = x + 0.68) { 32 | for (double y = 0.0; y < 1; y = y + 0.68) { 33 | if (level == 3) { 34 | g2d.drawImage(SpritesProvider.whirlStay[anim / 10 % 2], coordx + (int) (dz * x), coordy + (int) (dz * y), zoom / 3, zoom / 3, null); 35 | } 36 | if (level == 2) { 37 | g2d.drawImage(getSprite(), coordx + (int) (dz * x), coordy + (int) (dz * y), zoom / 3, zoom / 3, null); 38 | } 39 | } 40 | } 41 | } 42 | 43 | @Override 44 | public void drawThumbnail(Graphics2D g2d, int size) { 45 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 46 | drawInto(g2d, 0, 0, size, 3, null, 0, 0); 47 | } 48 | 49 | protected BufferedImage getSprite() { 50 | return SpritesProvider.whirlMove[anim % 2]; 51 | } 52 | 53 | @Override 54 | public void playMainSoundFor(SoundsBuffer rat) { 55 | rat.addToHarmQueue(SoundsBuffer.piskMuch); 56 | } 57 | 58 | @Override 59 | public void playSecondarySoundFor(SoundsBuffer rat) { 60 | rat.addToHarmQueue(SoundsBuffer.piskChr); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/sprites/RatSpriteSet.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.sprites; 2 | 3 | import java.awt.image.BufferedImage; 4 | 5 | public class RatSpriteSet { 6 | 7 | 8 | private final BufferedImage[][] sits; 9 | private final BufferedImage[][] eats; 10 | private final BufferedImage[][] runs; 11 | private final BufferedImage[][] falls; 12 | 13 | public RatSpriteSet(BufferedImage[] run, BufferedImage sit1, BufferedImage[] fall, BufferedImage eat) { 14 | sits = rotateImages(sit1); 15 | runs = rotateImages(run); 16 | falls = rotateImages(fall); 17 | if (eat == null) { 18 | eats = sits; 19 | } else { 20 | eats = rotateImages(eat); 21 | } 22 | } 23 | 24 | private BufferedImage[][] rotateImages(BufferedImage... run) { 25 | final BufferedImage[][] runs; 26 | BufferedImage[] runUp; 27 | BufferedImage[] runRight; 28 | BufferedImage[] runDown; 29 | BufferedImage[] runLeft; 30 | runUp = run; 31 | runRight = new BufferedImage[runUp.length]; 32 | runDown = new BufferedImage[runUp.length]; 33 | runLeft = new BufferedImage[runUp.length]; 34 | for (int x = 0; x < runUp.length; x++) { 35 | runRight[x] = SpritesProvider.rotate(runUp[x], 90); 36 | runDown[x] = SpritesProvider.rotate(runUp[x], 180); 37 | runLeft[x] = SpritesProvider.rotate(runUp[x], 270); 38 | } 39 | runs = new BufferedImage[][]{runUp, runRight, runDown, runLeft}; 40 | return runs; 41 | } 42 | 43 | public BufferedImage getSit(int direction, int anim) { 44 | return sits[direction][anim]; 45 | } 46 | 47 | public BufferedImage getEat(int direction, int anim) { 48 | return eats[direction][anim]; 49 | } 50 | 51 | public BufferedImage getRun(int direction, int anim) { 52 | return runs[direction][anim]; 53 | } 54 | 55 | public BufferedImage getFall(int direction, int anim) { 56 | return falls[direction][anim]; 57 | } 58 | 59 | public int getRuns() { 60 | return runs[0].length; 61 | } 62 | 63 | public int getFalls() { 64 | return falls[0].length; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/network/HelloCmd.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.network; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | import java.io.PrintWriter; 7 | import java.io.Serializable; 8 | import java.util.Objects; 9 | 10 | public class HelloCmd implements Serializable { 11 | public static final int MAX_TTL = 5; 12 | private static final GsonBuilder builder = new GsonBuilder(); 13 | private static Gson gson = builder.create(); 14 | 15 | private final String id; 16 | private final int port; 17 | private final String rat; 18 | private final String name; 19 | private transient int ttl = MAX_TTL; 20 | 21 | public HelloCmd(String id, int port, String rat, String name) { 22 | this.id = id; 23 | this.port = port; 24 | this.rat = rat; 25 | this.name = name; 26 | } 27 | 28 | public int getTtl() { 29 | return ttl; 30 | } 31 | 32 | public void setTtl(int ttl) { 33 | this.ttl = ttl; 34 | } 35 | 36 | public void ttl() { 37 | this.ttl = ttl -1; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public String getRat() { 45 | return rat; 46 | } 47 | 48 | public String getId() { 49 | return id; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return id + ":" + port + 55 | " " + rat + 56 | " " + name + ":" + ttl; 57 | } 58 | 59 | @Override 60 | public boolean equals(Object o) { 61 | if (o == null || getClass() != o.getClass()) return false; 62 | HelloCmd helloCmd = (HelloCmd) o; 63 | return port == helloCmd.port && Objects.equals(id, helloCmd.id) && Objects.equals(rat, helloCmd.rat) && Objects.equals(name, helloCmd.name); 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | return Objects.hash(id, port, rat, name); 69 | } 70 | 71 | public void send(PrintWriter ps) { 72 | String json = gson.toJson(this); 73 | ps.println(Commands.HANDSHAKE + json); 74 | } 75 | 76 | public static HelloCmd read(String s) { 77 | HelloCmd cmd = gson.fromJson(s, HelloCmd.class); 78 | return cmd; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/Utils.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import nonsense.hamsterrun.env.BaseBlock; 4 | import nonsense.hamsterrun.env.BlockField; 5 | import nonsense.hamsterrun.env.Maze; 6 | 7 | import java.awt.Graphics2D; 8 | import java.awt.Point; 9 | import java.awt.image.BufferedImage; 10 | 11 | public class Utils { 12 | public static void clear(BlockField[][] map, BaseBlock baseBlock, boolean passable) { 13 | for (int x = 0; x < map.length; x++) { 14 | for (int y = 0; y < map[x].length; y++) { 15 | if (map[x][y] == null) { 16 | map[x][y] = new BlockField(passable, new Point(x, y), baseBlock); 17 | } else { 18 | map[x][y].setPassable(passable); 19 | } 20 | } 21 | } 22 | } 23 | 24 | public static void column(BlockField[][] map, int y, boolean i) { 25 | for (int x = 0; x < map.length; x++) { 26 | map[x][y].setPassable(i); 27 | } 28 | } 29 | 30 | public static void row(BlockField[][] map, int x, boolean i) { 31 | for (int y = 0; y < map[x].length; y++) { 32 | map[x][y].setPassable(i); 33 | } 34 | } 35 | 36 | 37 | /* 38 | 00 10 12 .. 39 | 01 11 12 .. 40 | 02 ... 41 | ... 42 | */ 43 | public static BufferedImage toImage(BaseBlock map, int zoom, boolean mapOnly) { 44 | BufferedImage bi = new BufferedImage(map.getWidth() * zoom, map.getHeight() * zoom, BufferedImage.TYPE_INT_ARGB); 45 | Graphics2D g2d = bi.createGraphics(); 46 | map.drawMap(0, 0, zoom, g2d, 1, mapOnly, null); 47 | map.drawMap(0, 0, zoom, g2d, 2, mapOnly, null); 48 | map.drawMap(0, 0, zoom, g2d, 3, mapOnly, null); 49 | return bi; 50 | } 51 | 52 | 53 | public static BufferedImage toImage(Maze maze, int zoom, BaseConfig config, boolean map) { 54 | BufferedImage bi = new BufferedImage(maze.getWidth() * config.getBaseSize() * zoom, maze.getHeight() * config.getBaseSize() * zoom, BufferedImage.TYPE_INT_ARGB); 55 | Graphics2D g2d = bi.createGraphics(); 56 | maze.drawMap(0, 0, zoom, config, g2d, 1, map); 57 | maze.drawMap(0, 0, zoom, config, g2d, 2, map); 58 | maze.drawMap(0, 0, zoom, config, g2d, 3, map); 59 | return bi; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Tunnel.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.BlockField; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Color; 9 | import java.awt.Graphics2D; 10 | 11 | /** 12 | * Draws on second level, and if on cross road, the exit from it is random (on strigth, may go even back) 13 | */ 14 | public class Tunnel implements Item { 15 | 16 | public Color getMinimapColor() { 17 | return new Color(20, 20, 20); 18 | } 19 | 20 | @Override 21 | public void playMainSoundFor(SoundsBuffer rat) { 22 | rat.addToMoveQueue(SoundsBuffer.brbliTunel); 23 | } 24 | 25 | 26 | @Override 27 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 28 | if (level == 3) { 29 | g2d.drawImage(SpritesProvider.tunnelOpened, coordx, coordy, zoom, zoom, null); 30 | if (neigbours != null) { 31 | BlockField lb = neigbours.getLeftField(x, y); 32 | if (lb == null || lb.isImpassable() || lb.getItem() instanceof Tunnel) { 33 | g2d.drawImage(SpritesProvider.tunnelClosed[3], coordx, coordy, zoom, zoom, null); 34 | } 35 | BlockField rb = neigbours.getRightField(x, y); 36 | if (rb == null || rb.isImpassable() || rb.getItem() instanceof Tunnel) { 37 | g2d.drawImage(SpritesProvider.tunnelClosed[1], coordx, coordy, zoom, zoom, null); 38 | } 39 | BlockField ub = neigbours.getUpField(x, y); 40 | if (ub == null || ub.isImpassable() || ub.getItem() instanceof Tunnel) { 41 | g2d.drawImage(SpritesProvider.tunnelClosed[0], coordx, coordy, zoom, zoom, null); 42 | } 43 | BlockField db = neigbours.getDownField(x, y); 44 | if (db == null || db.isImpassable() || db.getItem() instanceof Tunnel) { 45 | g2d.drawImage(SpritesProvider.tunnelClosed[2], coordx, coordy, zoom, zoom, null); 46 | } 47 | } 48 | } 49 | } 50 | 51 | @Override 52 | public void drawThumbnail(Graphics2D g2d, int size) { 53 | drawInto(g2d, 0, 0, size, 3, null, 0, 0); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/Fire.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.env.BaseBlockNeigbours; 4 | import nonsense.hamsterrun.env.SoundsBuffer; 5 | import nonsense.hamsterrun.sprites.SpritesProvider; 6 | 7 | import java.awt.AlphaComposite; 8 | import java.awt.Color; 9 | import java.awt.Graphics2D; 10 | import java.awt.image.BufferedImage; 11 | 12 | //will try to turn rat to oposite direction and will be taking energy away 13 | //burns - a bit, on neighbour fields 14 | public class Fire implements Item { 15 | //will remove energy on passing through 16 | 17 | int anim = seed.nextInt(48); 18 | int anim2 = seed.nextInt(6); 19 | 20 | public Color getMinimapColor() { 21 | return Color.red; 22 | } 23 | 24 | @Override 25 | public void playMainSoundFor(SoundsBuffer rat) { 26 | rat.addToHarmQueue(SoundsBuffer.piskMuch); 27 | } 28 | 29 | @Override 30 | public void playSecondarySoundFor(SoundsBuffer rat) { 31 | rat.addToHarmQueue(SoundsBuffer.piskFire); 32 | } 33 | 34 | @Override 35 | public void playTercialSoundFor(SoundsBuffer rat) { 36 | rat.addToHarmQueue(SoundsBuffer.brbliFire); 37 | } 38 | 39 | @Override 40 | public void drawInto(Graphics2D g2d, int coordx, int coordy, int zoom, int level, BaseBlockNeigbours neigbours, int x, int y) { 41 | if (level == 2) { 42 | anim2++; 43 | if (anim2 > 5) { 44 | anim2 = 0; 45 | } 46 | g2d.drawImage(SpritesProvider.fire[anim2], coordx, coordy, zoom, zoom, null); 47 | } 48 | if (level == 3) { 49 | float opacity = 0.75f; 50 | anim++; 51 | if (anim > 49) { 52 | anim = 0; 53 | } 54 | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity)); 55 | g2d.drawImage(getSprite(anim / 10 + 1), coordx - zoom / 2, coordy - zoom / 2, zoom + zoom, zoom + zoom, null); 56 | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1)); 57 | } 58 | } 59 | 60 | @Override 61 | public void drawThumbnail(Graphics2D g2d, int size) { 62 | drawInto(g2d, 0, 0, size, 2, null, 0, 0); 63 | drawInto(g2d, 0, 0, size, 3, null, 0, 0); 64 | } 65 | 66 | protected BufferedImage getSprite(int id) { 67 | return SpritesProvider.glow[id]; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/BigFlies.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | //moving chaotically aka ai mouse 12 | //must be faster then rats... maybe different thread then repl? Maybe special % in repl? 13 | public class BigFlies extends MovingOne { 14 | 15 | protected int chaos = seed.nextInt(5) + 10; 16 | protected boolean moving = false; 17 | 18 | public BigFlies() { 19 | this.speed = seed.nextInt(2) + 2; 20 | this.anim = new AnimationCounrer(1000); 21 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 22 | } 23 | 24 | @Override 25 | protected boolean returnOnSalat(World world) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean selfAct(World world) { 31 | this.action = RatActions.WALK; 32 | ComputerControl.dummyMove(this, world, chaos); 33 | if (isMoving()) { 34 | move(world); 35 | } 36 | anim.addLimited(); 37 | return true; 38 | } 39 | 40 | private boolean isMoving() { 41 | if (seed.nextInt(chaos) == 0) { 42 | moving = !moving; 43 | } 44 | return moving; 45 | } 46 | 47 | @Override 48 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 49 | 50 | } 51 | 52 | 53 | @Override 54 | protected String getSkin() { 55 | return "bigFlies"; 56 | } 57 | 58 | @Override 59 | public void interact(Rat rat, World world) { 60 | if (rat.getAction() == RatActions.STAY || rat.getAction() == RatActions.EAT) { 61 | playMainSoundFor(rat.getSounds()); 62 | rat.setActionDirection(RatActions.WALK, RatActions.Direction.getRandom()); 63 | rat.speed = relativeSizes; 64 | } 65 | if (rat.getAction() == RatActions.WALK) { 66 | playMainSoundFor(rat.getSounds()); 67 | rat.setActionDirection(RatActions.WALK, rat.direction); 68 | rat.speed = relativeSizes; 69 | } 70 | } 71 | 72 | @Override 73 | public void playMainSoundFor(SoundsBuffer rat) { 74 | rat.addToHarmQueue(SoundsBuffer.brbliTunel); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/SmallFlies.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | //moving chaotically aka ai mouse 12 | //must be faster then rats... maybe different thread then repl? Maybe special % in repl? 13 | public class SmallFlies extends MovingOne { 14 | 15 | protected int chaos = seed.nextInt(30) + 10; 16 | protected boolean moving = false; 17 | 18 | public SmallFlies() { 19 | this.speed = seed.nextInt(4) + 3; 20 | this.anim = new AnimationCounrer(1000); 21 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 22 | } 23 | 24 | @Override 25 | protected boolean returnOnSalat(World world) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean selfAct(World world) { 31 | this.action = RatActions.WALK; 32 | ComputerControl.dummyMove(this, world, chaos); 33 | if (isMoving()) { 34 | move(world); 35 | } 36 | anim.addLimited(); 37 | return true; 38 | } 39 | 40 | private boolean isMoving() { 41 | if (seed.nextInt(chaos) == 0) { 42 | moving = !moving; 43 | } 44 | return moving; 45 | } 46 | 47 | @Override 48 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 49 | 50 | } 51 | 52 | 53 | @Override 54 | protected String getSkin() { 55 | return "smallFlies"; 56 | } 57 | 58 | @Override 59 | public void interact(Rat rat, World world) { 60 | if (rat.getAction() == RatActions.STAY || rat.getAction() == RatActions.EAT) { 61 | playMainSoundFor(rat.getSounds()); 62 | rat.setActionDirection(RatActions.WALK, RatActions.Direction.getRandom()); 63 | rat.speed = relativeSizes; 64 | } 65 | if (rat.getAction() == RatActions.WALK) { 66 | playMainSoundFor(rat.getSounds()); 67 | rat.setActionDirection(RatActions.WALK, rat.direction); 68 | rat.speed = relativeSizes; 69 | } 70 | } 71 | 72 | @Override 73 | public void playMainSoundFor(SoundsBuffer rat) { 74 | rat.addToHarmQueue(SoundsBuffer.brbliTunel); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/Cat.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | //running through maze and hunting rats 12 | public class Cat extends MovingOne { 13 | protected int chaos = seed.nextInt(30) + 10; 14 | protected boolean moving = false; 15 | private String currentSkin = "cat1"; 16 | 17 | public Cat() { 18 | this.speed = seed.nextInt(5) + 3; 19 | this.anim = new AnimationCounrer(1000); 20 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 21 | } 22 | 23 | 24 | @Override 25 | protected boolean returnOnSalat(World world) { 26 | return false; 27 | } 28 | 29 | 30 | @Override 31 | public boolean selfAct(World world) { 32 | if (isMoving()) { 33 | this.action = RatActions.WALK; 34 | } else { 35 | this.action = RatActions.STAY; 36 | } 37 | ComputerControl.niceMove(this, world, chaos); 38 | if (direction == RatActions.Direction.LEFT) { 39 | currentSkin = "cat2"; 40 | } 41 | if (direction == RatActions.Direction.RIGHT) { 42 | currentSkin = "cat1"; 43 | } 44 | if (isMoving()) { 45 | move(world); 46 | } 47 | anim.addLimited(); 48 | return true; 49 | } 50 | 51 | private boolean isMoving() { 52 | if (moving) { 53 | if (seed.nextInt(chaos) == 0) { 54 | moving = false; 55 | } 56 | } else { 57 | if (seed.nextInt(chaos) <= chaos / 2) { 58 | moving = true; 59 | } 60 | } 61 | return moving; 62 | } 63 | 64 | @Override 65 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 66 | 67 | } 68 | 69 | @Override 70 | protected String getSkin() { 71 | return currentSkin; 72 | } 73 | 74 | @Override 75 | public void interact(Rat rat, World world) { 76 | playMainSoundFor(rat.getSounds()); 77 | rat.adjustScore(-1000); 78 | } 79 | 80 | @Override 81 | public void playMainSoundFor(SoundsBuffer rat) { 82 | rat.addToHarmQueue(SoundsBuffer.piskMuch); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/BlockField.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.env.traps.Cage; 5 | import nonsense.hamsterrun.env.traps.Empty; 6 | import nonsense.hamsterrun.env.traps.Item; 7 | 8 | import java.awt.Point; 9 | import java.util.List; 10 | import java.util.Random; 11 | 12 | public class BlockField { 13 | 14 | private static long calls; 15 | private final Point coords; 16 | private final BaseBlock parent; 17 | private boolean passable; 18 | //to ahve only one item and one alien is simply simplification 19 | private Item item = new Empty(); 20 | 21 | public BlockField(boolean passable, Point coords, BaseBlock parent) { 22 | this.passable = passable; 23 | this.coords = coords; 24 | this.parent = parent; 25 | } 26 | 27 | 28 | public boolean isPassable() { 29 | return passable; 30 | } 31 | 32 | public void setPassable(boolean passable) { 33 | this.passable = passable; 34 | } 35 | 36 | public boolean isImpassable() { 37 | return !passable; 38 | } 39 | 40 | public Item getItem() { 41 | return item; 42 | } 43 | 44 | public boolean isFree() { 45 | return item == null; 46 | } 47 | 48 | public void clear() { 49 | this.item = new Empty(); 50 | } 51 | 52 | public Point getCoords() { 53 | return coords; 54 | } 55 | 56 | public BaseBlock getParent() { 57 | return parent; 58 | } 59 | 60 | public Point getUniversalCoords() { 61 | return Rat.toUniversalCoords(getParent().getCoords(), getCoords()); 62 | } 63 | 64 | public void setRandomObstacle(Random seed) { 65 | calls++; 66 | if (calls > Long.MAX_VALUE / 2) { 67 | calls = 0; 68 | } 69 | List recalcualted = ItemsWithBoundaries.recalculateToBoundaries(BaseConfig.getConfig().getItemsProbabilities()); 70 | int i = seed.nextInt(recalcualted.get(recalcualted.size() - 1).upper); 71 | for (ItemsWithBoundaries item : recalcualted) { 72 | if (i >= item.lower && i < item.upper) { 73 | this.item = ItemsWithBoundaries.itemClassToItemCatched(item.clazz); 74 | //this should prevent more then one gate on time 75 | if (this.item instanceof Cage) { 76 | if (calls < Math.pow(BaseConfig.getConfig().getGridSize() * BaseConfig.getConfig().getBaseSize(), 2) / 2) { 77 | this.item = new Empty(); 78 | } else { 79 | calls = 0; 80 | } 81 | } 82 | break; 83 | } 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/Key.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.RatActions; 5 | import nonsense.hamsterrun.env.SoundsBuffer; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 8 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 9 | import nonsense.hamsterrun.sprites.SpritesProvider; 10 | 11 | import java.awt.Graphics2D; 12 | import java.awt.Point; 13 | 14 | //moving well, over maze, better then random mous 15 | //maybe future pc2?-) 16 | //rats collects keys together 17 | //must be faster then rats... maybe different thread then repl? Maybe special % in repl? 18 | public class Key extends MovingOne { 19 | protected int chaos = seed.nextInt(10) + 10; 20 | 21 | public Key() { 22 | this.speed = seed.nextInt(5) + 3; 23 | this.anim = new AnimationCounrer(1000); 24 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 25 | } 26 | 27 | @Override 28 | public void drawMapExtension(Graphics2D g2d, Point leftUpCornerOfMaze, int zoom, World world) { 29 | super.drawMapExtension(g2d, leftUpCornerOfMaze, zoom, world); 30 | Point coord = getUniversalCoords(); 31 | g2d.drawLine(leftUpCornerOfMaze.x + (world.getWidth()/2) * zoom + zoom / 2, leftUpCornerOfMaze.y + (world.getHeight()/2) * zoom + zoom / 2, 32 | leftUpCornerOfMaze.x + coord.x * zoom + zoom / 2, leftUpCornerOfMaze.y + coord.y * zoom + zoom / 2); 33 | 34 | } 35 | 36 | 37 | @Override 38 | protected boolean returnOnSalat(World world) { 39 | return false; 40 | } 41 | 42 | 43 | @Override 44 | public boolean selfAct(World world) { 45 | this.action = RatActions.WALK; 46 | ComputerControl.niceMove(this, world, chaos); 47 | move(world); 48 | anim.addLimited(); 49 | for (Rat rat : world.getRats()) { 50 | if (getUniversalCoords().equals(rat.getUniversalCoords())) { 51 | playMainSoundFor(rat.getSounds()); 52 | for (Rat ratK : world.getRats()) { 53 | ratK.addKey(); 54 | } 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | 62 | @Override 63 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 64 | 65 | } 66 | 67 | @Override 68 | protected String getSkin() { 69 | return "key"; 70 | } 71 | 72 | @Override 73 | public void interact(Rat rat, World world) { 74 | 75 | } 76 | 77 | @Override 78 | public void playMainSoundFor(SoundsBuffer rat) { 79 | rat.addToHarmQueue(SoundsBuffer.piskLong); 80 | } 81 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Guinea Pig run through maze 2 | 3 | But in reallity you play with guinea pigs. 4 | 5 | ``` 6 | cd HamsterRun 7 | DISPLAY=:0 mvn clean install 8 | java -cp ./target/hamsterrun-1.0-SNAPSHOT.jar:$HOME/.m2/repository/com/google/code/gson/gson/2.13.1/gson-2.13.1.jar nonsense.hamsterrun.setup.SetupWindow 9 | ``` 10 | 11 | Without any argumetn setup window will pop up. 12 | 13 | The cmdline launcher takes a lot of args, see: https://github.com/judovana/HamsterRun/blob/main/src/main/java/nonsense/hamsterrun/Main.java#L45-L135ji 14 | 15 | There exists czech mutation, feel free to force it via `LANG=cs_CZ.UTF-8` 16 | 17 | 18 | The goal of the game is to get as much escaped Guine Pigs back to the golden cage (https://github.com/judovana/HamsterRun/blob/main/src/main/resources/nonsense/hamsterrun/sprites/gate.png) after you get fat by eating a lot of vegetables, and collecting several golden keys (https://github.com/judovana/HamsterRun/blob/main/src/main/resources/nonsense/hamsterrun/sprites/aliens/key.gif), and survivced all the traps. 19 | 20 | Note that it is collaborative game (AI is not exactly understanding this), and you all win, only after ALL guinea pigs are back in cage. The keys are comons shared proeprty, but score from vegetable is individual. 21 | The game is pretty hard on defaults - wi recomend to disable most of the obstacles, and enemies for first tries. Also reduce the necessesary amount of keys and score. 22 | 23 | The only way how to lost, is that all enemies will be repalced by immortal ghosts. In such case no new key will appear, and if you do not have necessary amount, you can not win. 24 | 25 | ## Movement 26 | Do not hold the keys. It will immediately swap you to turbo mode. Instead, one press on key, will change the direction and the rat is then going in that direction, untill it wishes. You can not stop it, it stops on it own. If you press again in the same dirrection, your speed rises. After several presses (or longer hold) it reaches super speed (there is sound for that border), and in that speed you can miss also obstacless/enemies, however some traps are hurting much *much* **much** more. So carefully. Of course in turbo speed you ca not eat. It is more probable you will stop on vegetable then elsewhere. Haveyou ever had guinea pigs? they mve exactly like this... 27 | 28 | ## Endless fresh world 29 | The game is based on invisible perpetual changes to labyrinth, thus providing ilusion of enldess cave. The place you (any guinea pig) stay never changes, and the neigbrhood spaces never changes! So you will never see a change on zoomed-in map. Also well placed rats may casue the world tobe immutable. The game world changes periodically (you can disbale that) and by pressing the key (you can disable this too). If aliens are out of passable terrain (except hawk and ghost) after regeneration, they are destroyed, and new one pops out. 30 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/sprites/GifToImages.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.sprites; 2 | 3 | import org.w3c.dom.NamedNodeMap; 4 | import org.w3c.dom.Node; 5 | import org.w3c.dom.NodeList; 6 | 7 | import javax.imageio.ImageIO; 8 | import javax.imageio.ImageReader; 9 | import javax.imageio.metadata.IIOMetadata; 10 | import javax.imageio.stream.ImageInputStream; 11 | 12 | import java.awt.image.BufferedImage; 13 | import java.io.IOException; 14 | import java.net.URL; 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class GifToImages { 21 | 22 | public static List decodeCatched(URL u) { 23 | try { 24 | return decode(u); 25 | } catch (IOException e) { 26 | e.printStackTrace(); 27 | return new ArrayList<>(); 28 | } 29 | } 30 | 31 | public static List decode(URL u) throws IOException { 32 | List result = new ArrayList<>(); 33 | String[] imageatt = new String[]{"imageLeftPosition", "imageTopPosition", "imageWidth", "imageHeight"}; 34 | 35 | ImageReader reader = (ImageReader) ImageIO.getImageReadersByFormatName("gif").next(); 36 | ImageInputStream ciis = ImageIO.createImageInputStream(u.openStream()); 37 | reader.setInput(ciis, false); 38 | 39 | int noi = reader.getNumImages(true); 40 | BufferedImage master = null; 41 | 42 | for (int i = 0; i < noi; i++) { 43 | BufferedImage image = reader.read(i); 44 | IIOMetadata metadata = reader.getImageMetadata(i); 45 | 46 | Node tree = metadata.getAsTree("javax_imageio_gif_image_1.0"); 47 | NodeList children = tree.getChildNodes(); 48 | 49 | for (int j = 0; j < children.getLength(); j++) { 50 | Node nodeItem = children.item(j); 51 | 52 | if (nodeItem.getNodeName().equals("ImageDescriptor")) { 53 | Map imageAttr = new HashMap<>(); 54 | 55 | for (int k = 0; k < imageatt.length; k++) { 56 | NamedNodeMap attr = nodeItem.getAttributes(); 57 | Node attnode = attr.getNamedItem(imageatt[k]); 58 | imageAttr.put(imageatt[k], Integer.valueOf(attnode.getNodeValue())); 59 | } 60 | 61 | //if (i == 0) { //this seems wrong - it draws all iages to single master 62 | master = new BufferedImage(imageAttr.get("imageWidth"), imageAttr.get("imageHeight"), BufferedImage.TYPE_INT_ARGB); 63 | //} 64 | master.getGraphics().drawImage(image, imageAttr.get("imageLeftPosition"), imageAttr.get("imageTopPosition"), null); 65 | } 66 | } 67 | result.add(master); 68 | } 69 | return result; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/MouseControl.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.env.Rat; 5 | import nonsense.hamsterrun.env.World; 6 | 7 | import java.awt.Point; 8 | import java.awt.event.InputEvent; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseWheelEvent; 11 | 12 | public class MouseControl extends HumanControl { 13 | 14 | Point lastPosition = new Point(0, 0); 15 | private long lastMove = System.currentTimeMillis(); 16 | 17 | @Override 18 | public String id() { 19 | return "m1"; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "mouse move wheel wheel-click double-click tripple-click"; 25 | } 26 | 27 | 28 | public void actW(Rat rat, MouseWheelEvent ew, World world) { 29 | int notches = ew.getWheelRotation(); 30 | if (notches > 0) { 31 | zoomIn(); 32 | } else { 33 | zoomOut(); 34 | } 35 | } 36 | 37 | public void actM(Rat rat, MouseEvent em, World world) { 38 | if (System.currentTimeMillis() - lastMove < BaseConfig.getConfig().getMouseDelay()) { 39 | return; 40 | } 41 | if (Math.abs(lastPosition.x - em.getLocationOnScreen().x) > Math.abs(lastPosition.y - em.getLocationOnScreen().y)) { 42 | if (lastPosition.x - em.getLocationOnScreen().x < 0) { 43 | rat.setMouseRight(world); 44 | } else if (lastPosition.x - em.getLocationOnScreen().x > 0) { 45 | rat.setMouseLeft(world); 46 | } 47 | } else if (Math.abs(lastPosition.x - em.getLocationOnScreen().x) < Math.abs(lastPosition.y - em.getLocationOnScreen().y)) { 48 | if (lastPosition.y - em.getLocationOnScreen().y < 0) { 49 | rat.setMouseDown(world); 50 | } else if (lastPosition.y - em.getLocationOnScreen().y > 0) { 51 | rat.setMouseUp(world); 52 | } 53 | } 54 | lastPosition = em.getLocationOnScreen(); 55 | lastMove = System.currentTimeMillis(); 56 | } 57 | 58 | public void actC(Rat rat, MouseEvent em, World world) { 59 | if ((em.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) { 60 | //we actually need two maps - anymated and non anymated.. 61 | map = !map; 62 | } 63 | if ((em.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 && em.getClickCount() >= 2) { 64 | world.regenerateAll(); 65 | } 66 | //keep those two? Made it configurable? 67 | //yes! per player? Yes! 68 | if ((em.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 && em.getClickCount() == 2) { 69 | world.allRatsSpread(true); 70 | } 71 | if ((em.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 && em.getClickCount() == 3) { 72 | world.allRatsSpread(false); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/ScoreListener.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.env.Rat; 5 | 6 | import javax.swing.JLabel; 7 | import javax.swing.SwingUtilities; 8 | 9 | import java.awt.Color; 10 | 11 | public class ScoreListener { 12 | 13 | private final JLabel label; 14 | private final Blinker blinker; 15 | private int lastScore = 0; 16 | 17 | public ScoreListener(JLabel scoreShow, Rat rat) { 18 | this.label = scoreShow; 19 | this.label.setOpaque(true); 20 | blinker = new Blinker(rat.getSkin() + " - " + rat); 21 | } 22 | 23 | private static Color getDefaultColor() { 24 | return Color.lightGray; 25 | } 26 | 27 | public void report(Rat rat, int score, int keys) { 28 | if (lastScore < score) { 29 | blinker.setColor(Color.green); 30 | } else if (lastScore > score) { 31 | blinker.setColor(Color.red); 32 | } else { 33 | blinker.setColor(getDefaultColor()); 34 | } 35 | lastScore = score; 36 | label.setText(rat.getSkin() + ": " + score + 37 | "/" + BaseConfig.getConfig().getIndividualMinimalScoreToEnterGoldenGate() + 38 | "/ "+ BaseConfig.getConfig().getCumulativeMinimalScoreToEnterGoldenGate() + 39 | " (keys: " + keys + "/" + BaseConfig.getConfig().getCumulativeMinimalNUmberOfKeys() + ")"); 40 | } 41 | 42 | private class Blinker extends Thread { 43 | 44 | Color color = getDefaultColor(); 45 | int counter = 0; 46 | 47 | public Blinker(String name) { 48 | this.setDaemon(true); 49 | this.setName("blinker " + name); 50 | this.start(); 51 | } 52 | 53 | public void setColor(Color color) { 54 | this.color = color; 55 | counter = 9; 56 | } 57 | 58 | @Override 59 | public void run() { 60 | while (true) { 61 | try { 62 | if (counter >= 0) { 63 | if (counter % 2 == 1) { 64 | SwingUtilities.invokeLater(new Runnable() { 65 | @Override 66 | public void run() { 67 | label.setBackground(color); 68 | label.repaint(); 69 | } 70 | }); 71 | } else { 72 | SwingUtilities.invokeLater(new Runnable() { 73 | @Override 74 | public void run() { 75 | label.setBackground(getDefaultColor()); 76 | label.repaint(); 77 | } 78 | }); 79 | } 80 | } 81 | counter--; 82 | if (counter < 0) { 83 | counter = -1; 84 | } 85 | Thread.sleep(100); 86 | } catch (Exception ex) { 87 | 88 | } 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/ItemsWithBoundaries.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.InvocationTargetException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | import nonsense.hamsterrun.BaseConfig; 10 | import nonsense.hamsterrun.env.aliens.MovingOne; 11 | import nonsense.hamsterrun.env.traps.Item; 12 | 13 | public class ItemsWithBoundaries { 14 | 15 | private static final boolean logItemsSpreading = false; 16 | 17 | //0 == disabled 18 | public final Class clazz; 19 | public final int lower; 20 | public final int upper; 21 | 22 | public ItemsWithBoundaries(Class clazz, int lower, int upper) { 23 | this.clazz = clazz; 24 | this.lower = lower; 25 | this.upper = upper; 26 | } 27 | 28 | public static List recalculateToBoundaries(List itemsWithProbabilities) { 29 | int maxSum = itemsWithProbabilities.stream().map(a -> a.ratio).collect(Collectors.summingInt(Integer::intValue)); 30 | List recalcualted = new ArrayList<>(itemsWithProbabilities.size()); 31 | int usedSum = 0; 32 | float probabCheck = 0; 33 | for (BaseConfig.ItemsWithProbability item : itemsWithProbabilities) { 34 | if (item.ratio > 0) { 35 | recalcualted.add(new ItemsWithBoundaries(item.clazz, usedSum, usedSum + item.ratio)); 36 | usedSum = usedSum + item.ratio; 37 | logItemSpreading("Adding " + item.clazz.getSimpleName() + " as " + recalcualted.size() + " of (max) " + itemsWithProbabilities.size()); 38 | float probab = ((float) item.ratio / (float) maxSum * (float) 100); 39 | probabCheck += probab; 40 | logItemSpreading(" Probability is " + probab + " %"); 41 | } 42 | } 43 | logItemSpreading("Total: " + probabCheck + " %"); 44 | if (usedSum != maxSum) { 45 | throw new RuntimeException("Author can not count"); 46 | } 47 | if (recalcualted.isEmpty()) { 48 | throw new RuntimeException("At least empty wall must be present"); 49 | } 50 | return recalcualted; 51 | } 52 | 53 | private static void logItemSpreading(String s) { 54 | if (logItemsSpreading) { 55 | System.out.println(s); 56 | } 57 | } 58 | 59 | public static Item itemClassToItemCatched(Class clazz) { 60 | try { 61 | return itemClassToItem(clazz); 62 | } catch (Exception e) { 63 | throw new RuntimeException(e); 64 | } 65 | } 66 | 67 | public static Item itemClassToItem(Class clazz) throws NoSuchMethodException, InstantiationException, IllegalAccessException, 68 | InvocationTargetException { 69 | Constructor ctor = clazz.getConstructor(); 70 | Object object = ctor.newInstance(); 71 | return (Item) object; 72 | } 73 | 74 | public static MovingOne alienClassToItemCatched(Class clazz) { 75 | try { 76 | return alienClassToItem(clazz); 77 | } catch (Exception e) { 78 | throw new RuntimeException(e); 79 | } 80 | } 81 | 82 | public static MovingOne alienClassToItem(Class clazz) throws NoSuchMethodException, InstantiationException, IllegalAccessException, 83 | InvocationTargetException { 84 | Constructor ctor = clazz.getConstructor(); 85 | Object object = ctor.newInstance(); 86 | return (MovingOne) object; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/RatActions.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import java.util.Random; 4 | 5 | public enum RatActions { 6 | 7 | STAY, WALK, EAT, FALLING(false); 8 | 9 | private final boolean interruptible; 10 | 11 | RatActions() { 12 | interruptible = true; 13 | } 14 | 15 | 16 | RatActions(boolean interruptible) { 17 | this.interruptible = interruptible; 18 | } 19 | 20 | public static boolean isStay(RatActions action) { 21 | return action == STAY; 22 | } 23 | 24 | public static boolean isWalk(RatActions action) { 25 | return action == WALK; 26 | } 27 | 28 | public boolean isInterruptible() { 29 | return interruptible; 30 | } 31 | 32 | public enum Direction { 33 | UP(0), RIGHT(1), DOWN(2), LEFT(3); 34 | 35 | private static final Random seed = new Random(); 36 | private final int sprite; 37 | 38 | Direction(int sprite) { 39 | this.sprite = sprite; 40 | } 41 | 42 | public static Direction getRandom() { 43 | int random = seed.nextInt(4); 44 | return Direction.values()[random]; 45 | } 46 | 47 | public Direction opposite() { 48 | if (this == UP) { 49 | return DOWN; 50 | } else if (this == DOWN) { 51 | return UP; 52 | } else if (this == LEFT) { 53 | return RIGHT; 54 | } else if (this == RIGHT) { 55 | return LEFT; 56 | } else { 57 | throw new RuntimeException("Where am I oposing?"); 58 | } 59 | } 60 | 61 | public Direction left() { 62 | if (this == UP) { 63 | return LEFT; 64 | } else if (this == DOWN) { 65 | return RIGHT; 66 | } else if (this == LEFT) { 67 | return UP; 68 | } else if (this == RIGHT) { 69 | return DOWN; 70 | } else { 71 | throw new RuntimeException("Where am I turning left?"); 72 | } 73 | } 74 | 75 | public Direction right() { 76 | if (this == UP) { 77 | return RIGHT; 78 | } else if (this == DOWN) { 79 | return LEFT; 80 | } else if (this == LEFT) { 81 | return DOWN; 82 | } else if (this == RIGHT) { 83 | return UP; 84 | } else { 85 | throw new RuntimeException("Where am I turning right?"); 86 | } 87 | } 88 | 89 | public int getSprite() { 90 | return sprite; 91 | } 92 | 93 | public Direction rotateCW() { 94 | switch (this) { 95 | case UP: 96 | return RIGHT; 97 | case RIGHT: 98 | return DOWN; 99 | case DOWN: 100 | return LEFT; 101 | case LEFT: 102 | return UP; 103 | default: 104 | throw new RuntimeException("Can not rotate: " + this); 105 | } 106 | } 107 | 108 | public Direction rotateCCW() { 109 | switch (this) { 110 | case UP: 111 | return LEFT; 112 | case RIGHT: 113 | return UP; 114 | case DOWN: 115 | return RIGHT; 116 | case LEFT: 117 | return DOWN; 118 | default: 119 | throw new RuntimeException("Can not rotate: " + this); 120 | } 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | nonsense 7 | hamsterrun 8 | 1.0-SNAPSHOT 9 | 10 | hamsterrun 11 | 12 | http://www.example.com 13 | 14 | 15 | UTF-8 16 | 17 17 | 18 | 19 | 20 | 21 | 22 | org.junit 23 | junit-bom 24 | 5.11.0 25 | pom 26 | import 27 | 28 | 29 | 30 | 31 | 32 | 33 | com.google.code.gson 34 | gson 35 | 2.13.1 36 | 37 | 38 | org.junit.jupiter 39 | junit-jupiter-api 40 | test 41 | 42 | 43 | 44 | org.junit.jupiter 45 | junit-jupiter-params 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | maven-clean-plugin 56 | 3.4.0 57 | 58 | 59 | 60 | maven-resources-plugin 61 | 3.3.1 62 | 63 | 64 | maven-compiler-plugin 65 | 3.13.0 66 | 67 | 68 | maven-surefire-plugin 69 | 3.3.0 70 | 71 | 72 | maven-jar-plugin 73 | 3.4.2 74 | 75 | 76 | maven-install-plugin 77 | 3.1.2 78 | 79 | 80 | maven-deploy-plugin 81 | 3.1.2 82 | 83 | 84 | 85 | maven-site-plugin 86 | 3.12.1 87 | 88 | 89 | maven-project-info-reports-plugin 90 | 3.6.1 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/test/java/nonsense/hamsterrun/UtilsTest.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import nonsense.hamsterrun.env.BaseBlock; 4 | import nonsense.hamsterrun.env.BlockField; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.awt.Point; 9 | import java.util.Arrays; 10 | import java.util.Random; 11 | 12 | public class UtilsTest { 13 | 14 | @Test 15 | public void clearTest() { 16 | BlockField[][] map = new BlockField[2][3]; 17 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), true); 18 | Assertions.assertArrayEquals(new Boolean[]{true, true, true}, Arrays.stream(map[0]).map(a -> a.isPassable()).toArray()); 19 | Assertions.assertArrayEquals(new Boolean[]{true, true, true}, Arrays.stream(map[1]).map(a -> a.isPassable()).toArray()); 20 | 21 | map = new BlockField[3][2]; 22 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), true); 23 | Assertions.assertArrayEquals(new Boolean[]{true, true}, Arrays.stream(map[0]).map(a -> a.isPassable()).toArray()); 24 | Assertions.assertArrayEquals(new Boolean[]{true, true}, Arrays.stream(map[1]).map(a -> a.isPassable()).toArray()); 25 | Assertions.assertArrayEquals(new Boolean[]{true, true}, Arrays.stream(map[2]).map(a -> a.isPassable()).toArray()); 26 | } 27 | 28 | @Test 29 | public void columnTest() { 30 | BlockField[][] map = new BlockField[2][2]; 31 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), false); 32 | Utils.column(map, 0, true); 33 | Assertions.assertEquals(true, map[0][0].isPassable()); 34 | Assertions.assertEquals(true, map[1][0].isPassable()); 35 | Assertions.assertEquals(false, map[0][1].isPassable()); 36 | Assertions.assertEquals(false, map[1][1].isPassable()); 37 | Utils.column(map, 0, false); 38 | Utils.column(map, 1, true); 39 | Assertions.assertEquals(false, map[0][0].isPassable()); 40 | Assertions.assertEquals(false, map[1][0].isPassable()); 41 | Assertions.assertEquals(true, map[0][1].isPassable()); 42 | Assertions.assertEquals(true, map[1][1].isPassable()); 43 | } 44 | 45 | @Test 46 | public void rowTest() { 47 | BlockField[][] map = new BlockField[2][2]; 48 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), false); 49 | Utils.row(map, 0, true); 50 | Assertions.assertEquals(true, map[0][0].isPassable()); 51 | Assertions.assertEquals(true, map[0][1].isPassable()); 52 | Assertions.assertEquals(false, map[1][1].isPassable()); 53 | Assertions.assertEquals(false, map[1][0].isPassable()); 54 | Utils.row(map, 0, false); 55 | Utils.row(map, 1, true); 56 | Assertions.assertEquals(false, map[0][0].isPassable()); 57 | Assertions.assertEquals(false, map[0][1].isPassable()); 58 | Assertions.assertEquals(true, map[1][1].isPassable()); 59 | Assertions.assertEquals(true, map[1][0].isPassable()); 60 | } 61 | 62 | @Test 63 | public void rowColumnTest() { 64 | BlockField[][] map = new BlockField[2][2]; 65 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), false); 66 | Utils.row(map, 0, true); 67 | Utils.column(map, 0, true); 68 | Assertions.assertEquals(true, map[0][0].isPassable()); 69 | Assertions.assertEquals(true, map[0][1].isPassable()); 70 | Assertions.assertEquals(false, map[1][1].isPassable()); 71 | Assertions.assertEquals(true, map[1][0].isPassable()); 72 | Utils.clear(map, new BaseBlock(3, new Point(-1, -1)), false); 73 | Utils.row(map, 1, true); 74 | Utils.column(map, 1, true); 75 | Assertions.assertEquals(false, map[0][0].isPassable()); 76 | Assertions.assertEquals(true, map[0][1].isPassable()); 77 | Assertions.assertEquals(true, map[1][1].isPassable()); 78 | Assertions.assertEquals(true, map[1][0].isPassable()); 79 | } 80 | 81 | @Test 82 | public void random2az3() { 83 | Random seed = new Random(); 84 | for (int x = 0; x < 10000000; x++) { 85 | int a = seed.nextInt(2) + 2; 86 | Assertions.assertTrue(a == 2 || a == 3); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/setup/PresetConfigs.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.setup; 2 | 3 | import nonsense.hamsterrun.Localization; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import javax.swing.DefaultComboBoxModel; 7 | import javax.swing.JButton; 8 | import javax.swing.JLabel; 9 | import javax.swing.JList; 10 | import javax.swing.JOptionPane; 11 | import javax.swing.JPanel; 12 | import javax.swing.JScrollPane; 13 | import javax.swing.JTextArea; 14 | import javax.swing.event.ListSelectionEvent; 15 | import javax.swing.event.ListSelectionListener; 16 | import java.awt.BorderLayout; 17 | import java.awt.GridLayout; 18 | import java.awt.event.ActionEvent; 19 | import java.awt.event.ActionListener; 20 | import java.net.URL; 21 | import java.util.Arrays; 22 | import java.util.List; 23 | 24 | public class PresetConfigs extends JPanel implements Localized { 25 | 26 | private static class LocalisedListItem { 27 | private final String id; 28 | private static final String namesapce1 = "nonsense/hamsterrun/preconf"; 29 | private static final String namesapce2 = namesapce1.replace("/", "."); 30 | 31 | public LocalisedListItem(String id) { 32 | this.id = id; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return Localization.get().get(namesapce2 + ".name." + id); 38 | } 39 | 40 | public URL getResource() { 41 | return this.getClass().getClassLoader().getResource(namesapce1 + "/" + id); 42 | } 43 | 44 | public String getDescription() { 45 | return Localization.get().get(namesapce2 + ".desc." + id); 46 | } 47 | 48 | } 49 | 50 | private static List knownConfigs = Arrays.asList( 51 | new LocalisedListItem("paradise"), 52 | new LocalisedListItem("fireworld"), 53 | new LocalisedListItem("traps"), 54 | new LocalisedListItem("hunt"), 55 | new LocalisedListItem("hawk"), 56 | new LocalisedListItem("waterworld") 57 | ); 58 | 59 | private final JButton load; 60 | private final JList configs; 61 | private final JScrollPane scrollConfigs; 62 | private final JTextArea info; 63 | 64 | 65 | public PresetConfigs(World world, SetupWindow parent) { 66 | this.setLayout(new GridLayout(0, 2)); 67 | JPanel upperHalf = new JPanel(new BorderLayout()); 68 | JPanel bottomHalf = new JPanel(new BorderLayout()); 69 | this.add(upperHalf); 70 | this.add(bottomHalf); 71 | configs = new JList(knownConfigs.toArray()); 72 | configs.addListSelectionListener(new ListSelectionListener() { 73 | @Override 74 | public void valueChanged(ListSelectionEvent e) { 75 | if (configs.getSelectedValue() != null) { 76 | info.setText(configs.getSelectedValue().getDescription()); 77 | load.setEnabled(true); 78 | } else { 79 | info.setText(""); 80 | load.setEnabled(false); 81 | } 82 | } 83 | }); 84 | scrollConfigs = new JScrollPane(configs); 85 | upperHalf.add(scrollConfigs); 86 | info = new JTextArea(); 87 | info.setEditable(false); 88 | info.setLineWrap(true); 89 | bottomHalf.add(info); 90 | load = new JButton("load"); 91 | load.addActionListener(new ActionListener() { 92 | @Override 93 | public void actionPerformed(ActionEvent e) { 94 | try { 95 | MiscPanel.loadConfig(configs.getSelectedValue().getResource().openStream(), world, parent); 96 | } catch (Exception ex) { 97 | JOptionPane.showMessageDialog(PresetConfigs.this, ex); 98 | } 99 | } 100 | }); 101 | load.setEnabled(false); 102 | bottomHalf.add(load, BorderLayout.SOUTH); 103 | setTitles(); 104 | } 105 | 106 | @Override 107 | public void setTitles() { 108 | load.setText(Localization.get().get("load")); 109 | setName(Localization.get().getPresetConfigsTitle()); 110 | configs.setModel(new DefaultComboBoxModel(knownConfigs.toArray(new LocalisedListItem[0]))); 111 | 112 | } 113 | 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/VirtualRatSetup.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 4 | import nonsense.hamsterrun.ratcontroll.ComputerControl2; 5 | import nonsense.hamsterrun.ratcontroll.KeyboardControl1; 6 | import nonsense.hamsterrun.ratcontroll.KeyboardControl2; 7 | import nonsense.hamsterrun.ratcontroll.KeyboardControl3; 8 | import nonsense.hamsterrun.ratcontroll.MouseControl; 9 | import nonsense.hamsterrun.ratcontroll.RatsController; 10 | import nonsense.hamsterrun.sprites.SpritesProvider; 11 | 12 | import java.util.stream.Collectors; 13 | 14 | public class VirtualRatSetup { 15 | 16 | protected String def; 17 | protected int aiChaos; 18 | protected boolean display; 19 | protected String skin; 20 | protected String controlDef; 21 | 22 | 23 | public VirtualRatSetup(String def, int aiChaos, boolean display, String skin, String control) { 24 | this.def = def; 25 | this.aiChaos = aiChaos; 26 | this.display = display; 27 | this.skin = skin; 28 | this.controlDef = control; 29 | } 30 | 31 | //syntax control:skin:haveDisplay:aiModifier eg k1:uhlicek:true or pc:rat:false:10 32 | public static VirtualRatSetup parse(String def) { 33 | int aiChaos = RatsController.DEFAULT_CHAOS; 34 | boolean display = false; 35 | String skin = null; 36 | RatsController.RatControl control = null; 37 | String[] rataParams = def.split(":"); 38 | for (int i = 0; i < rataParams.length; i++) { 39 | String param = rataParams[i]; 40 | switch (i) { 41 | case 3: 42 | aiChaos = Integer.valueOf(param); 43 | break; 44 | case 2: 45 | display = Boolean.valueOf(param); 46 | break; 47 | case 1: 48 | if (SpritesProvider.KNOWN_RATS.contains(param)) { 49 | skin = param; 50 | } else { 51 | throw new RuntimeException("Unknown sprite " + param + ". Available are " + SpritesProvider.KNOWN_RATS.stream().collect(Collectors.joining(","))); 52 | } 53 | break; 54 | case 0: 55 | control = stringToRatControl(def, param); 56 | break; 57 | } 58 | } 59 | return new VirtualRatSetup(def, aiChaos, display, skin, control.id()); 60 | } 61 | 62 | public static RatsController.RatControl stringToRatControl(String origDef, String param) { 63 | RatsController.RatControl control; 64 | if (param.equalsIgnoreCase("pc1")) { 65 | control = new ComputerControl(); 66 | }else if (param.equalsIgnoreCase("pc2")) { 67 | control = new ComputerControl2(); 68 | } else if (param.equalsIgnoreCase("k1")) { 69 | control = new KeyboardControl1(); 70 | } else if (param.equalsIgnoreCase("k2")) { 71 | control = new KeyboardControl2(); 72 | } else if (param.equalsIgnoreCase("k3")) { 73 | control = new KeyboardControl3(); 74 | } else if (param.equalsIgnoreCase("m1")) { 75 | control = new MouseControl(); 76 | } else { 77 | throw new RuntimeException("unknown param in rat def: " + param + " in " + origDef); 78 | } 79 | return control; 80 | } 81 | 82 | @Override 83 | public String toString() { 84 | return controlDef + ":" + skin + ":" + display + ":" + aiChaos; 85 | } 86 | 87 | public String getDef() { 88 | return def; 89 | } 90 | 91 | public void setDef(String def) { 92 | this.def = def; 93 | } 94 | 95 | public int getAiChaos() { 96 | return aiChaos; 97 | } 98 | 99 | public void setAiChaos(int aiChaos) { 100 | this.aiChaos = aiChaos; 101 | } 102 | 103 | public boolean isDisplay() { 104 | return display; 105 | } 106 | 107 | public void setDisplay(boolean display) { 108 | this.display = display; 109 | } 110 | 111 | public String getSkin() { 112 | return skin; 113 | } 114 | 115 | public void setSkin(String skin) { 116 | this.skin = skin; 117 | } 118 | 119 | public String getControlDef() { 120 | return controlDef; 121 | } 122 | 123 | public void setControlDef(String controlDef) { 124 | this.controlDef = controlDef; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/traps/TwoWayTeleport.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.traps; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.env.Rat; 5 | import nonsense.hamsterrun.env.World; 6 | import nonsense.hamsterrun.sprites.SpritesProvider; 7 | 8 | import java.awt.Point; 9 | import java.awt.image.BufferedImage; 10 | import java.io.IOException; 11 | import java.util.ArrayList; 12 | import java.util.Collections; 13 | import java.util.List; 14 | 15 | public class TwoWayTeleport extends Teleport { 16 | 17 | private static final boolean disableSelfDirection = true; 18 | 19 | //will drop the mouse to unassigned gate. the gate will become assigned 20 | //it MUST drop it NEXT to it, otherwise it will cause endless loop 21 | //if all gates are assigned, then to random one? 22 | 23 | private Point targetGate; 24 | 25 | private static List findTeleportWithoutGate(List twoWayTeleports, World world) throws IOException { 26 | Collections.shuffle(twoWayTeleports); 27 | List realTwoWayTeleports = new ArrayList<>(twoWayTeleports.size()); 28 | for (Point point : twoWayTeleports) { 29 | Item item = world.getBlockField(point).getItem(); 30 | if (item instanceof TwoWayTeleport) { 31 | realTwoWayTeleports.add(point); 32 | } 33 | } 34 | if (realTwoWayTeleports.isEmpty()) { 35 | throw new IOException("No two way tleports in world!"); 36 | } 37 | List unallocatedTwoWayTeleports = new ArrayList<>(twoWayTeleports.size()); 38 | for (Point point : realTwoWayTeleports) { 39 | TwoWayTeleport item = (TwoWayTeleport) world.getBlockField(point).getItem(); 40 | if (item.targetGate == null) { 41 | unallocatedTwoWayTeleports.add(point); 42 | } 43 | } 44 | if (unallocatedTwoWayTeleports.isEmpty()) { 45 | ((TwoWayTeleport) world.getBlockField(realTwoWayTeleports.get(0)).getItem()).targetGate = null; 46 | unallocatedTwoWayTeleports.add(realTwoWayTeleports.get(0)); 47 | } 48 | return unallocatedTwoWayTeleports; 49 | } 50 | 51 | @Override 52 | protected BufferedImage getSprite(int id) { 53 | return SpritesProvider.getTwoWayTeleport(id); 54 | } 55 | 56 | @Override 57 | public void relocate(World world, Rat rat) { 58 | List twoWayTeleports = new ArrayList<>(); 59 | for (int x = 0; x < BaseConfig.getConfig().getGridSize() * BaseConfig.getConfig().getBaseSize(); x++) { 60 | for (int y = 0; y < BaseConfig.getConfig().getGridSize() * BaseConfig.getConfig().getBaseSize(); y++) { 61 | Item item = world.getBlockField(new Point(x, y)).getItem(); 62 | if (item instanceof TwoWayTeleport) { 63 | System.out.println("Found teleport at " + x + ":" + y + "; rat is at " + rat.getUniversalCoords()); 64 | twoWayTeleports.add(new Point(x, y)); 65 | } 66 | } 67 | } 68 | if (twoWayTeleports.isEmpty()) { 69 | System.out.println("No destination!"); 70 | return; 71 | } 72 | if (disableSelfDirection) { 73 | if (twoWayTeleports.size() > 1) { 74 | twoWayTeleports.remove(rat.getUniversalCoords()); 75 | } 76 | } 77 | try { 78 | if (targetGate == null) { 79 | twoWayTeleports = findTeleportWithoutGate(twoWayTeleports, world); 80 | targetGate = twoWayTeleports.get(0); 81 | ((TwoWayTeleport) world.getBlockField(targetGate).getItem()).targetGate = rat.getUniversalCoords(); 82 | } else { 83 | Item item = world.getBlockField(targetGate).getItem(); 84 | if (item instanceof TwoWayTeleport) { 85 | System.out.println("Moving to set place"); 86 | } else { 87 | twoWayTeleports = findTeleportWithoutGate(twoWayTeleports, world); 88 | targetGate = twoWayTeleports.get(0); 89 | ((TwoWayTeleport) world.getBlockField(targetGate).getItem()).targetGate = rat.getUniversalCoords(); 90 | } 91 | 92 | } 93 | moveRatTo(world, rat, targetGate); 94 | } catch (IOException ex) { 95 | ex.printStackTrace(); 96 | moveRatTo(world, rat, rat.getUniversalCoords()); 97 | } 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/SoundsBuffer.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class SoundsBuffer { 7 | 8 | public static final String turbo = "turbo"; 9 | public static final String eat = "chroup"; 10 | public static final String piskMuch = "pisk1"; 11 | public static final String piskChr = "pisk3"; 12 | public static final String piskLong = "pisk5"; 13 | public static final String piskWeird = "pisk4"; 14 | public static final String brbliFall = "brblibrbli2"; 15 | public static final String brbliTele = "brblibrbli3"; 16 | public static final String brbliFire = "brblibrbli1"; 17 | public static final String piskFire = "pisk2"; 18 | public static final String brbliTunel = "brblibrbli4"; 19 | private final SoundQueue moveQueue = createSoundQueue(); 20 | private final SoundQueue eatQueue = createSoundQueue(); 21 | private final SoundQueue harmQueue = createSoundQueue(); 22 | 23 | protected SoundQueue createSoundQueue() { 24 | return new SoundQueue(); 25 | } 26 | 27 | public void addToMoveQueue(String clip) { 28 | moveQueue.enqueue(clip); 29 | } 30 | 31 | public void addToEatQueue(String clip) { 32 | eatQueue.enqueue(clip); 33 | } 34 | 35 | public void addToHarmQueue(String clip) { 36 | harmQueue.enqueue(clip); 37 | } 38 | 39 | public void kill() { 40 | if (harmQueue != null) { 41 | harmQueue.kill(); 42 | } 43 | if (eatQueue != null) { 44 | eatQueue.kill(); 45 | } 46 | if (moveQueue != null) { 47 | moveQueue.kill(); 48 | } 49 | 50 | } 51 | 52 | private static class SoundQueue implements Runnable { 53 | private static int id; 54 | private static int LIMIT = 15; 55 | List queue = new ArrayList<>(10); 56 | WavSoundPlayer player = null; 57 | private boolean live = true; 58 | 59 | public SoundQueue() { 60 | id++; 61 | Thread t = new Thread(this); 62 | t.setDaemon(true); 63 | t.setName("Sound queue " + id); 64 | t.start(); 65 | } 66 | 67 | @Override 68 | public void run() { 69 | while (live) { 70 | try { 71 | Thread.sleep(50); 72 | String what = peak(); 73 | if (what == null) { 74 | continue; 75 | } else { 76 | if (player == null || player.isFinished()) { 77 | //if there is no playback, item in peak is played 78 | player = new WavSoundPlayer(dequeue()); 79 | player.rawPlayAsync(); 80 | } else { 81 | //if player already plays whats in queue, it is removed 82 | if (player.getWhat().equals(what)) { 83 | dequeue(); 84 | } 85 | } 86 | } 87 | } catch (Exception ex) { 88 | ex.printStackTrace(); 89 | } 90 | } 91 | } 92 | 93 | private void enqueue(String s) { 94 | if (queue.size() > LIMIT) { 95 | queue.clear(); 96 | } 97 | queue.add(s); 98 | } 99 | 100 | private String dequeue() { 101 | if (queue.size() > 0) { 102 | String member = queue.get(0); 103 | queue.remove(0); 104 | return member; 105 | } else { 106 | return null; 107 | } 108 | } 109 | 110 | private String peak() { 111 | if (queue.size() > 0) { 112 | String member = queue.get(0); 113 | return member; 114 | } else { 115 | return null; 116 | } 117 | } 118 | 119 | public void kill() { 120 | live = false; 121 | } 122 | } 123 | 124 | public static class NoSound extends SoundsBuffer { 125 | protected SoundQueue createSoundQueue() { 126 | return null; 127 | } 128 | 129 | public void addToMoveQueue(String clip) { 130 | 131 | } 132 | 133 | public void addToEatQueue(String clip) { 134 | 135 | } 136 | 137 | public void addToHarmQueue(String clip) { 138 | 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/Localization.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun; 2 | 3 | 4 | import java.util.Locale; 5 | import java.util.MissingResourceException; 6 | import java.util.ResourceBundle; 7 | 8 | public class Localization { 9 | 10 | private static Localization instance = new Localization(); 11 | private ResourceBundle bundle = ResourceBundle.getBundle("messages"); 12 | 13 | public static Localization get() { 14 | return instance; 15 | } 16 | 17 | public String getOr(String name) { 18 | try { 19 | String translation = get(name); 20 | if (translation == null || translation.isEmpty()) { 21 | return "No text for: " + name; 22 | } else { 23 | return translation; 24 | } 25 | } catch (MissingResourceException ex) { 26 | System.err.println(name); 27 | return "No text for: " + name; 28 | } 29 | } 30 | 31 | public String get(String key) { 32 | return bundle.getString(key); 33 | } 34 | 35 | public String getHello() { 36 | return get("hello"); 37 | } 38 | 39 | 40 | public void toUs() { 41 | bundle = ResourceBundle.getBundle("messages", Locale.US); 42 | } 43 | 44 | public void toCz() { 45 | bundle = ResourceBundle.getBundle("messages", Locale.forLanguageTag("cs-CZ")); 46 | } 47 | 48 | 49 | public String getMainTitle() { 50 | return get("mainTitle"); 51 | } 52 | 53 | public String getWorldTitle() { 54 | return get("worldTitle"); 55 | } 56 | 57 | public String getMiscTitle() { 58 | return get("miscTitle"); 59 | } 60 | 61 | public String getNetTitle() { 62 | return get("netTitle"); 63 | } 64 | 65 | public String getItemsTitle() { 66 | return get("itemsTitle"); 67 | } 68 | 69 | public String getBaseConfigLabel() { 70 | return get("baseConfiglabel"); 71 | } 72 | 73 | public String getGridConfigLabel() { 74 | return get("gridConfiglabel"); 75 | } 76 | 77 | public String getRegSpeedLabel() { 78 | return get("regSpeedLabel"); 79 | } 80 | 81 | public String baseDensityMaxLabel() { 82 | return get("baseDensityMaxLabel"); 83 | } 84 | 85 | public String baseDensityMinLabel() { 86 | return get("baseDensityMinLabel"); 87 | } 88 | 89 | public String gridConnectivityMinLabel() { 90 | return get("gridConnectivityMinLabel"); 91 | } 92 | 93 | public String gridConnectivityMaxLabel() { 94 | return get("gridConnectivityMaxLabel"); 95 | } 96 | 97 | public String getRatsTitle() { 98 | return get("ratsTitle"); 99 | } 100 | 101 | public String getAddMousesButton1() { 102 | return get("addMousesButton1"); 103 | } 104 | 105 | public String getAddMousesButton2() { 106 | return get("addMousesButton2"); 107 | } 108 | 109 | public String getColumnsLabel() { 110 | return get("columnsLabel"); 111 | } 112 | 113 | public String getStartGame() { 114 | return get("startGame"); 115 | } 116 | 117 | public String delayMs() { 118 | return get("delayMs"); 119 | } 120 | 121 | public String getKeepRegenerating() { 122 | return get("keepRegenerating"); 123 | } 124 | 125 | public String getRemoveMe() { 126 | return get("removeMe"); 127 | } 128 | 129 | public String getNoPreview() { 130 | return get("noPreview"); 131 | } 132 | 133 | public String getImagePreview() { 134 | return get("imagePreview"); 135 | } 136 | 137 | public String getFullPreview() { 138 | return get("fullPreview"); 139 | } 140 | 141 | public String getDisableAll() { 142 | return get("disableAll"); 143 | } 144 | 145 | public String getResetFields() { 146 | return get("resetFields"); 147 | } 148 | 149 | public String getDisabledOnZero() { 150 | return get("disabledOnZero"); 151 | } 152 | 153 | public String getAllAliensDisabled() { 154 | return get("allAliensDisabled"); 155 | } 156 | 157 | public String maxAliensLabel() { 158 | return get("maxAliensLabel"); 159 | } 160 | 161 | public String getResumeGame() { 162 | return get("resume"); 163 | } 164 | 165 | public String getPresetConfigsTitle() { 166 | return get("presetConfigsTitle"); 167 | } 168 | 169 | public Object getNoRatWarning() { 170 | return get("noRatWarning"); 171 | } 172 | 173 | public String getOkConnected() { 174 | return get("okConnected"); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/ratcontroll/RatsController.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.ratcontroll; 2 | 3 | import nonsense.hamsterrun.env.Rat; 4 | import nonsense.hamsterrun.env.World; 5 | 6 | import java.awt.Choice; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Random; 10 | import java.util.stream.Collectors; 11 | 12 | public class RatsController implements RatsProvider { 13 | 14 | //TODO make this configurable? 15 | public static final int DEFAULT_CHAOS = 20; 16 | 17 | 18 | static final Random seed = new Random(); 19 | 20 | private List rats = new ArrayList<>(4); 21 | public static final HighScore highScore = new HighScore(); 22 | 23 | public void addRat(RatWithControls ratWithControls) { 24 | this.rats.add(ratWithControls); 25 | } 26 | 27 | @Override 28 | public List getRats() { 29 | return rats.stream().filter(a -> a != null && a.rat != null).map(a -> a.rat).collect(Collectors.toUnmodifiableList()); 30 | } 31 | 32 | private List getRatsWithControlls() { 33 | return rats.stream().filter(a -> a != null && a.rat != null).collect(Collectors.toUnmodifiableList()); 34 | } 35 | 36 | @Override 37 | public RatControl getRatControl(Rat rat) { 38 | for (RatWithControls rats: rats){ 39 | if (rats.rat == rat) { 40 | return rats.ratControl; 41 | } 42 | } 43 | return null; 44 | } 45 | 46 | @Override 47 | public void swap(Rat rat) { 48 | RatWithControls current = rats.get(seed.nextInt(rats.size())); 49 | for (int x = 0; x < 5; x++) { 50 | RatWithControls future = rats.get(seed.nextInt(rats.size())); 51 | if (future == current) { 52 | continue; 53 | } else { 54 | RatControl currentControl = current.getRatControl(); 55 | RatControl futureControl = future.getRatControl(); 56 | current.setRatControl(futureControl); 57 | future.setRatControl(currentControl); 58 | break; 59 | } 60 | } 61 | 62 | 63 | } 64 | 65 | @Override 66 | public void kill() { 67 | for (Rat rat : this.getRats()) { 68 | rat.getSounds().kill(); 69 | } 70 | rats.clear(); 71 | } 72 | 73 | @Override 74 | public void remove(Rat rat, long time) { 75 | //FIXME introduce some time and score results. 76 | //if such resutls will not be empty, show... 77 | //eg on the empty screen after palyer left 78 | //eg on the exit 79 | long tscore = 0; 80 | for (int x = 0; x < rats.size(); x++) { 81 | tscore += rats.get(x).rat.getScore(); 82 | } 83 | for (int x = 0; x < rats.size(); x++) { 84 | this.highScore.add(new Score(rat.getSkin(), this.getRatControl(rat).id(), time, rat.getScore(), tscore)); 85 | if (rats.get(x).rat == rat) { 86 | //this is intentionaly before removal, to ensure, some score will be still missing 87 | int scoreBonus = rat.getScore()/rats.size(); 88 | rats.remove(x); 89 | for (int y = 0; y < rats.size(); y++) { 90 | rats.get(y).rat.adjustScore(scoreBonus); 91 | } 92 | x--;// or break? can there be duplicates? 93 | } 94 | } 95 | } 96 | 97 | public KeyboardControl getNulLControl() { 98 | for (RatWithControls ratsconts : rats) { 99 | if (ratsconts.rat == null) { 100 | return (KeyboardControl) (ratsconts.ratControl); 101 | } 102 | } 103 | return null; 104 | } 105 | 106 | public interface RatControl { 107 | 108 | void selfAct(Rat rat, World world); 109 | 110 | int getZoom(); 111 | 112 | void zoomIn(); 113 | 114 | void zoomOut(); 115 | 116 | boolean isDisplay(); 117 | 118 | void setDisplay(Boolean aBoolean); 119 | 120 | void setChaos(int i); 121 | 122 | int getMap(); 123 | 124 | String id(); 125 | } 126 | 127 | public static class RatWithControls { 128 | private final Rat rat; 129 | private RatControl ratControl; 130 | 131 | public RatWithControls(Rat rat, RatControl ratControl) { 132 | this.rat = rat; 133 | this.ratControl = ratControl; 134 | } 135 | 136 | public RatControl getRatControl() { 137 | return ratControl; 138 | } 139 | 140 | public void setRatControl(RatControl ratControl) { 141 | this.ratControl = ratControl; 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/WavSoundPlayer.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env; 2 | 3 | import nonsense.hamsterrun.sprites.SpritesProvider; 4 | 5 | import javax.sound.sampled.AudioInputStream; 6 | import javax.sound.sampled.AudioSystem; 7 | import javax.sound.sampled.Clip; 8 | import javax.sound.sampled.Line; 9 | import javax.sound.sampled.LineUnavailableException; 10 | import javax.sound.sampled.Mixer; 11 | import javax.sound.sampled.UnsupportedAudioFileException; 12 | 13 | import java.io.ByteArrayInputStream; 14 | import java.io.ByteArrayOutputStream; 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | import java.net.URL; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | public class WavSoundPlayer { 22 | 23 | private static final Map cache = new HashMap<>(); 24 | private final String what; 25 | private boolean finished = false; 26 | 27 | public WavSoundPlayer(String what) { 28 | this.what = what; 29 | } 30 | 31 | public static Clip rawPlayCatched(String what) { 32 | try { 33 | return rawPlay(what); 34 | } catch (IOException e) { 35 | throw new RuntimeException(e); 36 | } catch (LineUnavailableException e) { 37 | throw new RuntimeException(e); 38 | } catch (UnsupportedAudioFileException e) { 39 | throw new RuntimeException(e); 40 | } 41 | } 42 | 43 | public static Clip rawPlay(String what) throws IOException, LineUnavailableException, UnsupportedAudioFileException { 44 | return WavSoundPlayer.rawPlay(what, 1f); 45 | } 46 | 47 | public static Clip rawPlay(String what, float volume) throws IOException, LineUnavailableException, UnsupportedAudioFileException { 48 | byte[] cached = cache.get(what); 49 | if (cached == null) { 50 | URL runUrl = SpritesProvider.class.getClassLoader().getResource("nonsense/hamsterrun/sounds/effects/" + what + ".wav"); 51 | cached = streamToBytes(runUrl.openStream()); 52 | cache.put(what, cached); 53 | } 54 | AudioInputStream audioStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(cached)); 55 | Clip clip = AudioSystem.getClip(); 56 | // FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); 57 | // FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.VOLUME); 58 | // float range = gainControl.getMaximum() - gainControl.getMinimum(); 59 | // float gain = (range * volume) + gainControl.getMinimum(); 60 | // gainControl.setValue(gain); 61 | clip.open(audioStream); 62 | clip.start();//oh, this is actually unblocking.... 63 | return clip; 64 | } 65 | 66 | private static byte[] streamToBytes(InputStream is) { 67 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 68 | try (is) { 69 | byte[] byteChunk = new byte[4096]; // Or whatever size you want to read in at a time. 70 | int n; 71 | while ((n = is.read(byteChunk)) > 0) { 72 | baos.write(byteChunk, 0, n); 73 | } 74 | } catch (IOException e) { 75 | throw new RuntimeException(e); 76 | } 77 | return baos.toByteArray(); 78 | } 79 | 80 | public static void main(String[] args) throws Exception { 81 | Mixer.Info[] mixers = AudioSystem.getMixerInfo(); 82 | System.out.println("There are " + mixers.length + " mixer info objects"); 83 | for (Mixer.Info mixerInfo : mixers) { 84 | System.out.println("mixer name: " + mixerInfo.getName()); 85 | Mixer mixer = AudioSystem.getMixer(mixerInfo); 86 | Line.Info[] lineInfos = mixer.getSourceLineInfo(); 87 | for (Line.Info lineInfo : lineInfos) { 88 | System.out.println(" Line.Info: " + lineInfo); 89 | } 90 | } 91 | 92 | WavSoundPlayer w = new WavSoundPlayer("chroup"); 93 | w.rawPlayAsync(); 94 | while (!w.finished) { 95 | Thread.sleep(50); 96 | System.out.println("Waiting?"); 97 | } 98 | 99 | } 100 | 101 | public boolean isFinished() { 102 | return finished; 103 | } 104 | 105 | public String getWhat() { 106 | return what; 107 | } 108 | 109 | public void rawPlayAsync() { 110 | new Thread() { 111 | public void run() { 112 | try { 113 | Clip clip = WavSoundPlayer.rawPlay(what); 114 | Thread.sleep(clip.getMicrosecondLength() / 1000); // Convert 115 | } catch (Exception e) { 116 | e.printStackTrace(); 117 | } finally { 118 | finished = true; 119 | } 120 | } 121 | }.start(); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/setup/SetupWindow.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.setup; 2 | 3 | import nonsense.hamsterrun.BaseConfig; 4 | import nonsense.hamsterrun.Localization; 5 | import nonsense.hamsterrun.Main; 6 | import nonsense.hamsterrun.env.World; 7 | import nonsense.hamsterrun.sprites.SpritesProvider; 8 | 9 | import javax.swing.JButton; 10 | import javax.swing.JFrame; 11 | import javax.swing.JOptionPane; 12 | import javax.swing.JPanel; 13 | import javax.swing.JTabbedPane; 14 | import javax.swing.SwingUtilities; 15 | import javax.swing.WindowConstants; 16 | import javax.swing.event.ChangeEvent; 17 | import javax.swing.event.ChangeListener; 18 | 19 | import java.awt.BorderLayout; 20 | import java.awt.event.ActionEvent; 21 | import java.awt.event.ActionListener; 22 | import java.awt.event.WindowAdapter; 23 | import java.awt.event.WindowEvent; 24 | 25 | 26 | public class SetupWindow extends JFrame implements Localized { 27 | 28 | private final JButton startButton; 29 | private final World pausedWorld; 30 | 31 | public SetupWindow(World world) { 32 | JTabbedPane tabs = new JTabbedPane(); 33 | final RatsPanel rats; 34 | if (world == null) { 35 | rats = new RatsPanel(); 36 | tabs.add(rats); 37 | } else { 38 | rats = null; 39 | } 40 | JPanel items = new ItemsAndAliensPanel(); 41 | tabs.add(items); 42 | tabs.add(new WorldPanel(world)); 43 | JPanel allowedControls = new MiscPanel(world, this); 44 | tabs.add(allowedControls); 45 | JPanel presetConfigs = new PresetConfigs(world, this); 46 | tabs.add(presetConfigs); 47 | if (world == null && rats != null) { 48 | JPanel networkConfigs = new NetworkPane(world, this, rats); 49 | tabs.add(networkConfigs); 50 | } 51 | add(tabs); 52 | tabs.addChangeListener(new ChangeListener() { 53 | @Override 54 | public void stateChanged(ChangeEvent changeEvent) { 55 | if (tabs.getSelectedComponent() instanceof NetworkPane) { 56 | startButton.setEnabled(false); 57 | if (world == null && rats != null) { 58 | //FIXME this is wrong, server can be started with no rats at all.. 59 | if (rats.getRatsWithView().isEmpty() ) { 60 | JOptionPane.showMessageDialog(null, Localization.get().getNoRatWarning()); 61 | tabs.setSelectedIndex(0); 62 | } 63 | } 64 | } else { 65 | startButton.setEnabled(true); 66 | } 67 | } 68 | }); 69 | if (world == null) { 70 | startButton = new JButton("start"); 71 | startButton.addActionListener(new ActionListener() { 72 | @Override 73 | public void actionPerformed(ActionEvent e) { 74 | start(); 75 | } 76 | }); 77 | add(startButton, BorderLayout.SOUTH); 78 | } else { 79 | SetupWindow.this.addWindowListener(new WindowAdapter() { 80 | @Override 81 | public void windowClosing(WindowEvent e) { 82 | world.resume(); 83 | } 84 | }); 85 | startButton = new JButton("resume"); 86 | startButton.addActionListener(new ActionListener() { 87 | @Override 88 | public void actionPerformed(ActionEvent e) { 89 | world.resume(); 90 | SetupWindow.this.dispose(); 91 | } 92 | }); 93 | add(startButton, BorderLayout.SOUTH); 94 | } 95 | setSize(800, 800); 96 | setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 97 | this.pausedWorld = world; 98 | setTitles(); 99 | setVisible(true); 100 | } 101 | 102 | public static void main(String[] args) throws Exception { 103 | if (args.length == 0) { 104 | BaseConfig config = BaseConfig.getConfig(); 105 | SpritesProvider.load(); 106 | config.summUp(); 107 | config.verify(); 108 | SwingUtilities.invokeLater(new Runnable() { 109 | @Override 110 | public void run() { 111 | new SetupWindow(null); 112 | } 113 | }); 114 | } else { 115 | Main.main(args); 116 | } 117 | } 118 | 119 | public void start() { 120 | this.dispose(); 121 | new Main().worldDemo(); 122 | } 123 | 124 | public void setTitles() { 125 | setTitle(Localization.get().getMainTitle()); 126 | if (pausedWorld == null) { 127 | startButton.setText(Localization.get().getStartGame()); 128 | } else { 129 | startButton.setText(Localization.get().getResumeGame()); 130 | } 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/nonsense/hamsterrun/env/aliens/Ghost.java: -------------------------------------------------------------------------------- 1 | package nonsense.hamsterrun.env.aliens; 2 | 3 | import java.awt.Point; 4 | import java.util.List; 5 | 6 | import nonsense.hamsterrun.env.Rat; 7 | import nonsense.hamsterrun.env.RatActions; 8 | import nonsense.hamsterrun.env.SoundsBuffer; 9 | import nonsense.hamsterrun.env.World; 10 | import nonsense.hamsterrun.env.traps.AnimationCounrer; 11 | import nonsense.hamsterrun.env.traps.Teleport; 12 | import nonsense.hamsterrun.ratcontroll.ComputerControl; 13 | import nonsense.hamsterrun.sprites.SpritesProvider; 14 | 15 | //walk through wall, scaryying them away? 16 | public class Ghost extends MovingOne { 17 | 18 | protected int chaos = seed.nextInt(30) + 10; 19 | protected boolean moving = false; 20 | private String currentSkin = "ghost1"; 21 | 22 | public Ghost() { 23 | this.speed = seed.nextInt(6) + 2; 24 | this.anim = new AnimationCounrer(1000); 25 | anim.reset(seed.nextInt(SpritesProvider.getAlienSize(getSkin()))); 26 | } 27 | 28 | @Override 29 | public boolean mustBeInCorridor() { 30 | return false; 31 | } 32 | 33 | @Override 34 | protected boolean returnOnSalat(World world) { 35 | return false; 36 | } 37 | 38 | protected void reallyMoveMouseRight(World world) { 39 | forceMouseRight(); 40 | } 41 | 42 | protected void reallyMoveMouseUp(World world) { 43 | forceMouseUp(); 44 | } 45 | 46 | protected void reallyMoveMouseLeft(World world) { 47 | forceMouseLeft(); 48 | } 49 | 50 | protected void reallyMoveMouseDown(World world) { 51 | forceMouseDown(); 52 | } 53 | 54 | @Override 55 | public boolean selfAct(World world) { 56 | if (getUniversalCoords().x < -world.getWidth() / 3 || getUniversalCoords().y < -world.getHeight() / 3 57 | || getUniversalCoords().x > world.getWidth() * 1.3 || getUniversalCoords().y > world.getHeight() * 1.3) { 58 | world.teleportMouse(this, false, false); 59 | } 60 | if (isMoving()) { 61 | this.action = RatActions.WALK; 62 | } else { 63 | this.action = RatActions.STAY; 64 | } 65 | ComputerControl.dummyMove(this, world, chaos); 66 | if (direction == RatActions.Direction.LEFT) { 67 | currentSkin = "ghost1"; 68 | } 69 | if (direction == RatActions.Direction.RIGHT) { 70 | currentSkin = "ghost2"; 71 | } 72 | if (isMoving()) { 73 | move(world); 74 | } 75 | try { 76 | scaryAway(world); 77 | }catch (Exception ex){ 78 | //this may throw, if the block is regenerated on the fly 79 | //it do not harm, no action, and jsut go on 80 | } 81 | anim.addLimited(); 82 | return true; 83 | } 84 | 85 | private void scaryAway(World world) { 86 | List neighbours1 = Teleport.getPassableNeighboursForGivenPoint(getUniversalCoords(), world); 87 | for (Point p1: neighbours1) { 88 | for (Rat rat: world.getRats()){ 89 | scared(p1, rat, 6); 90 | } 91 | List neighbours2 = Teleport.getPassableNeighboursForGivenPoint(p1, world); 92 | for (Point p2: neighbours2) { 93 | for (Rat rat: world.getRats()){ 94 | scared(p2, rat, 3); 95 | } 96 | } 97 | } 98 | } 99 | 100 | private static void scared(Point p, Rat rat, int val) { 101 | if (rat.getUniversalCoords().equals(p)){ 102 | rat.direction = RatActions.Direction.getRandom(); 103 | if (rat.action.isInterruptible()){ 104 | rat.action = RatActions.WALK; 105 | } 106 | if (rat.speed < val) { 107 | rat.speed = val; 108 | } 109 | } 110 | } 111 | 112 | private boolean isMoving() { 113 | if (moving) { 114 | if (seed.nextInt(chaos) == 0) { 115 | moving = false; 116 | } 117 | } else { 118 | if (seed.nextInt(chaos) <= chaos / 2) { 119 | moving = true; 120 | } 121 | } 122 | return moving; 123 | } 124 | 125 | @Override 126 | protected void adjustSpeedBeforeActionDirection(RatActions.Direction futureDirection) { 127 | 128 | } 129 | 130 | @Override 131 | protected String getSkin() { 132 | return currentSkin; 133 | } 134 | 135 | @Override 136 | public void interact(Rat rat, World world) { 137 | playMainSoundFor(rat.getSounds()); 138 | rat.adjustScore(-50); 139 | for (Rat rat2: world.getRats()) { 140 | rat2.removeKey(); 141 | } 142 | } 143 | 144 | @Override 145 | public void playMainSoundFor(SoundsBuffer rat) { 146 | rat.addToHarmQueue(SoundsBuffer.brbliFall); 147 | } 148 | 149 | @Override 150 | public void playSecondarySoundFor(SoundsBuffer rat) { 151 | rat.addToHarmQueue(SoundsBuffer.brbliTele); 152 | } 153 | } 154 | --------------------------------------------------------------------------------