├── core ├── AUTHORS ├── data │ ├── fonts │ │ ├── 16 │ │ │ ├── ocr_a.png │ │ │ ├── wellbutrin.png │ │ │ └── ocr_a_small.png │ │ └── 24 │ │ │ ├── ocr_a.png │ │ │ ├── wellbutrin.png │ │ │ └── ocr_a_small.png │ ├── sounds │ │ ├── bleep.ogg │ │ ├── buzz01.ogg │ │ ├── buzz05.ogg │ │ ├── hit01.ogg │ │ ├── hit02.ogg │ │ ├── hit03.ogg │ │ ├── pickup.ogg │ │ ├── achievement.ogg │ │ ├── electrifying01.ogg │ │ ├── standard_taunts │ │ │ ├── get_it.ogg │ │ │ ├── kill_it.ogg │ │ │ ├── attack_it.ogg │ │ │ ├── charge_it.ogg │ │ │ ├── destroy_it.ogg │ │ │ ├── get_the_humanoid.ogg │ │ │ ├── get_the_intruder.ogg │ │ │ ├── kill_the_humanoid.ogg │ │ │ ├── kill_the_intruder.ogg │ │ │ ├── attack_the_humanoid.ogg │ │ │ ├── attack_the_intruder.ogg │ │ │ ├── charge_the_humanoid.ogg │ │ │ ├── charge_the_intruder.ogg │ │ │ ├── destroy_the_humanoid.ogg │ │ │ └── destroy_the_intruder.ogg │ │ ├── captain_enter_room_speech.ogg │ │ ├── exit_room_as_chicken_speech.ogg │ │ └── chicken_taunts │ │ │ ├── get_the_chicken.ogg │ │ │ ├── kill_the_chicken.ogg │ │ │ ├── attack_the_chicken.ogg │ │ │ ├── charge_the_chicken.ogg │ │ │ └── destroy_the_chicken.ogg │ ├── textures │ │ ├── 16 │ │ │ ├── png1.png │ │ │ └── pack │ │ └── 24 │ │ │ ├── png1.png │ │ │ └── pack │ └── veryangryrobots.properties ├── src │ └── com │ │ └── badlydrawngames │ │ ├── veryangryrobots │ │ ├── IShowScores.java │ │ ├── ISubmitScores.java │ │ ├── mobiles │ │ │ ├── PlayerShot.java │ │ │ ├── BaseShot.java │ │ │ ├── RobotShot.java │ │ │ ├── Player.java │ │ │ ├── Captain.java │ │ │ ├── GameObject.java │ │ │ └── Robot.java │ │ ├── ScoringEventNotifier.java │ │ ├── ScoringEventListener.java │ │ ├── ScoreListener.java │ │ ├── FlyupManager.java │ │ ├── AchievementsListener.java │ │ ├── DifficultyManager.java │ │ ├── DoorPositions.java │ │ ├── Flyup.java │ │ ├── AchievementsNotifier.java │ │ ├── ScoreNotifier.java │ │ ├── WorldListener.java │ │ ├── VeryAngryRobotsGame.java │ │ ├── ParticleAdapter.java │ │ ├── WorldNotifier.java │ │ ├── SoundManager.java │ │ ├── ScoresScreen.java │ │ ├── StatusView.java │ │ ├── MazeGenerator.java │ │ ├── MainMenuScreen.java │ │ ├── WorldPresenter.java │ │ ├── RoomBuilder.java │ │ ├── ScoreBasedDifficultyManager.java │ │ └── StatusManager.java │ │ └── general │ │ ├── GameScreen.java │ │ ├── MathUtils.java │ │ ├── Rectangles.java │ │ ├── ParticleManager.java │ │ ├── Pools.java │ │ ├── ScoreString.java │ │ ├── Particle.java │ │ ├── Config.java │ │ ├── Grid.java │ │ ├── CollisionGeometry.java │ │ ├── SimpleButton.java │ │ ├── Colliders.java │ │ └── CameraHelper.java ├── build.gradle ├── .project ├── .classpath └── LICENSE ├── android ├── AUTHORS ├── res │ ├── drawable-hdpi │ │ └── icon.png │ ├── drawable-ldpi │ │ └── icon.png │ ├── drawable-mdpi │ │ └── icon.png │ ├── values │ │ └── strings.xml │ └── layout │ │ └── main.xml ├── assets │ └── data │ │ ├── fonts │ │ ├── 16 │ │ │ ├── ocr_a.png │ │ │ ├── wellbutrin.png │ │ │ └── ocr_a_small.png │ │ └── 24 │ │ │ ├── ocr_a.png │ │ │ ├── wellbutrin.png │ │ │ └── ocr_a_small.png │ │ ├── sounds │ │ ├── bleep.ogg │ │ ├── buzz01.ogg │ │ ├── buzz05.ogg │ │ ├── hit01.ogg │ │ ├── hit02.ogg │ │ ├── hit03.ogg │ │ ├── pickup.ogg │ │ ├── achievement.ogg │ │ ├── electrifying01.ogg │ │ ├── standard_taunts │ │ │ ├── get_it.ogg │ │ │ ├── kill_it.ogg │ │ │ ├── attack_it.ogg │ │ │ ├── charge_it.ogg │ │ │ ├── destroy_it.ogg │ │ │ ├── get_the_humanoid.ogg │ │ │ ├── get_the_intruder.ogg │ │ │ ├── kill_the_humanoid.ogg │ │ │ ├── kill_the_intruder.ogg │ │ │ ├── attack_the_humanoid.ogg │ │ │ ├── attack_the_intruder.ogg │ │ │ ├── charge_the_humanoid.ogg │ │ │ ├── charge_the_intruder.ogg │ │ │ ├── destroy_the_humanoid.ogg │ │ │ └── destroy_the_intruder.ogg │ │ ├── captain_enter_room_speech.ogg │ │ ├── exit_room_as_chicken_speech.ogg │ │ └── chicken_taunts │ │ │ ├── get_the_chicken.ogg │ │ │ ├── kill_the_chicken.ogg │ │ │ ├── attack_the_chicken.ogg │ │ │ ├── charge_the_chicken.ogg │ │ │ └── destroy_the_chicken.ogg │ │ ├── textures │ │ ├── 16 │ │ │ ├── png1.png │ │ │ └── pack │ │ └── 24 │ │ │ ├── png1.png │ │ │ └── pack │ │ └── veryangryrobots.properties ├── project.properties ├── default.properties ├── .classpath ├── src │ └── com │ │ └── badlydrawngames │ │ └── veryangryrobots │ │ └── android │ │ └── VeryAngryRobotsActivity.java ├── .project ├── AndroidManifest.xml ├── proguard.cfg ├── build.gradle └── LICENSE ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── desktop ├── src │ └── com │ │ └── badlydrawngames │ │ └── veryangryrobots │ │ └── DesktopStarter.java └── build.gradle ├── .gitignore ├── gradlew.bat └── gradlew /core/AUTHORS: -------------------------------------------------------------------------------- 1 | Rod Hyde (rod@badlydrawngames.com) -------------------------------------------------------------------------------- /android/AUTHORS: -------------------------------------------------------------------------------- 1 | Rod Hyde (rod@badlydrawngames.com) -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'core', 'desktop', 'android' -------------------------------------------------------------------------------- /core/data/fonts/16/ocr_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/16/ocr_a.png -------------------------------------------------------------------------------- /core/data/fonts/24/ocr_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/24/ocr_a.png -------------------------------------------------------------------------------- /core/data/sounds/bleep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/bleep.ogg -------------------------------------------------------------------------------- /core/data/sounds/buzz01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/buzz01.ogg -------------------------------------------------------------------------------- /core/data/sounds/buzz05.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/buzz05.ogg -------------------------------------------------------------------------------- /core/data/sounds/hit01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/hit01.ogg -------------------------------------------------------------------------------- /core/data/sounds/hit02.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/hit02.ogg -------------------------------------------------------------------------------- /core/data/sounds/hit03.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/hit03.ogg -------------------------------------------------------------------------------- /core/data/sounds/pickup.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/pickup.ogg -------------------------------------------------------------------------------- /core/data/textures/16/png1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/textures/16/png1.png -------------------------------------------------------------------------------- /core/data/textures/24/png1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/textures/24/png1.png -------------------------------------------------------------------------------- /core/data/fonts/16/wellbutrin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/16/wellbutrin.png -------------------------------------------------------------------------------- /core/data/fonts/24/wellbutrin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/24/wellbutrin.png -------------------------------------------------------------------------------- /core/data/sounds/achievement.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/achievement.ogg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /android/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /android/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /core/data/fonts/16/ocr_a_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/16/ocr_a_small.png -------------------------------------------------------------------------------- /core/data/fonts/24/ocr_a_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/fonts/24/ocr_a_small.png -------------------------------------------------------------------------------- /core/data/sounds/electrifying01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/electrifying01.ogg -------------------------------------------------------------------------------- /android/assets/data/fonts/16/ocr_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/16/ocr_a.png -------------------------------------------------------------------------------- /android/assets/data/fonts/24/ocr_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/24/ocr_a.png -------------------------------------------------------------------------------- /android/assets/data/sounds/bleep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/bleep.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/buzz01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/buzz01.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/buzz05.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/buzz05.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/hit01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/hit01.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/hit02.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/hit02.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/hit03.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/hit03.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/pickup.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/pickup.ogg -------------------------------------------------------------------------------- /android/assets/data/textures/16/png1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/textures/16/png1.png -------------------------------------------------------------------------------- /android/assets/data/textures/24/png1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/textures/24/png1.png -------------------------------------------------------------------------------- /android/assets/data/fonts/16/wellbutrin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/16/wellbutrin.png -------------------------------------------------------------------------------- /android/assets/data/fonts/24/wellbutrin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/24/wellbutrin.png -------------------------------------------------------------------------------- /android/assets/data/sounds/achievement.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/achievement.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/get_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/get_it.ogg -------------------------------------------------------------------------------- /android/assets/data/fonts/16/ocr_a_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/16/ocr_a_small.png -------------------------------------------------------------------------------- /android/assets/data/fonts/24/ocr_a_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/fonts/24/ocr_a_small.png -------------------------------------------------------------------------------- /android/assets/data/sounds/electrifying01.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/electrifying01.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/kill_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/kill_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/captain_enter_room_speech.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/captain_enter_room_speech.ogg -------------------------------------------------------------------------------- /core/data/sounds/exit_room_as_chicken_speech.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/exit_room_as_chicken_speech.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/attack_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/attack_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/charge_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/charge_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/destroy_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/destroy_it.ogg -------------------------------------------------------------------------------- /android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Very Angry Robots (free) 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libgdx-demo-very angry robots 2 | ==================== 3 | 4 | Libgdx demo - Very Angry Robots 5 | 6 | ![veryangryrobots](http://i.imgur.com/SHDyI07.png) 7 | 8 | -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/get_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/get_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/chicken_taunts/get_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/chicken_taunts/get_the_chicken.ogg -------------------------------------------------------------------------------- /core/data/sounds/chicken_taunts/kill_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/chicken_taunts/kill_the_chicken.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/get_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/get_the_humanoid.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/get_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/get_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/kill_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/kill_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/chicken_taunts/attack_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/chicken_taunts/attack_the_chicken.ogg -------------------------------------------------------------------------------- /core/data/sounds/chicken_taunts/charge_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/chicken_taunts/charge_the_chicken.ogg -------------------------------------------------------------------------------- /core/data/sounds/chicken_taunts/destroy_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/chicken_taunts/destroy_the_chicken.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/kill_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/kill_the_humanoid.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/kill_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/kill_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/captain_enter_room_speech.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/captain_enter_room_speech.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/exit_room_as_chicken_speech.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/exit_room_as_chicken_speech.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/attack_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/attack_it.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/charge_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/charge_it.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/destroy_it.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/destroy_it.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/attack_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/attack_the_humanoid.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/attack_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/attack_the_intruder.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/charge_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/charge_the_humanoid.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/charge_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/charge_the_intruder.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/destroy_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/destroy_the_humanoid.ogg -------------------------------------------------------------------------------- /core/data/sounds/standard_taunts/destroy_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/core/data/sounds/standard_taunts/destroy_the_intruder.ogg -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/IShowScores.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots; 3 | 4 | public interface IShowScores { 5 | void showScores (); 6 | } 7 | -------------------------------------------------------------------------------- /android/assets/data/sounds/chicken_taunts/get_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/chicken_taunts/get_the_chicken.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/chicken_taunts/kill_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/chicken_taunts/kill_the_chicken.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/get_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/get_the_humanoid.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/get_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/get_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/chicken_taunts/attack_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/chicken_taunts/attack_the_chicken.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/chicken_taunts/charge_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/chicken_taunts/charge_the_chicken.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/chicken_taunts/destroy_the_chicken.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/chicken_taunts/destroy_the_chicken.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/kill_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/kill_the_humanoid.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/kill_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/kill_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/attack_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/attack_the_humanoid.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/attack_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/attack_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/charge_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/charge_the_humanoid.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/charge_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/charge_the_intruder.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/destroy_the_humanoid.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/destroy_the_humanoid.ogg -------------------------------------------------------------------------------- /android/assets/data/sounds/standard_taunts/destroy_the_intruder.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgdx/libgdx-demo-very-angry-robots/HEAD/android/assets/data/sounds/standard_taunts/destroy_the_intruder.ogg -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ISubmitScores.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots; 3 | 4 | public interface ISubmitScores { 5 | void submitScore (final int score); 6 | } 7 | -------------------------------------------------------------------------------- /core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | sourceCompatibility = 1.6 4 | 5 | dependencies { 6 | compile "com.badlogicgames.gdx:gdx:$gdxVersion" 7 | } 8 | 9 | sourceSets.main.java.srcDirs = [ "src/" ] 10 | 11 | eclipse.project { 12 | name = appName + "-core" 13 | } 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 21 13:08:26 CEST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip 7 | -------------------------------------------------------------------------------- /android/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-17 12 | -------------------------------------------------------------------------------- /android/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-8 12 | -------------------------------------------------------------------------------- /core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | very-angry-robots 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/PlayerShot.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots.mobiles; 3 | 4 | import com.badlydrawngames.general.Config; 5 | import com.badlydrawngames.veryangryrobots.Assets; 6 | 7 | public class PlayerShot extends BaseShot { 8 | 9 | private static final float SHOT_SPEED = Config.asFloat("PlayerShot.speed", 31.25f); 10 | 11 | public PlayerShot () { 12 | width = Assets.playerShotWidth; 13 | height = Assets.playerShotHeight; 14 | setShotSpeed(SHOT_SPEED); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoringEventNotifier.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots; 3 | 4 | import com.badlogic.gdx.utils.Array; 5 | 6 | public class ScoringEventNotifier implements ScoringEventListener { 7 | 8 | private final Array listeners; 9 | 10 | public ScoringEventNotifier () { 11 | listeners = new Array(); 12 | } 13 | 14 | public void addListener (ScoringEventListener listener) { 15 | listeners.add(listener); 16 | } 17 | 18 | @Override 19 | public void onScoringEvent (float x, float y, int points) { 20 | for (ScoringEventListener listener : listeners) { 21 | listener.onScoringEvent(x, y, points); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoringEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | public interface ScoringEventListener { 17 | void onScoringEvent (float x, float y, int points); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoreListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | public interface ScoreListener { 17 | void onScoreChanged (int score); 18 | 19 | void onLivesChanged (int lives); 20 | } 21 | -------------------------------------------------------------------------------- /android/src/com/badlydrawngames/veryangryrobots/android/VeryAngryRobotsActivity.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots.android; 3 | 4 | import android.os.Bundle; 5 | 6 | import com.badlogic.gdx.backends.android.AndroidApplication; 7 | import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; 8 | import com.badlydrawngames.veryangryrobots.VeryAngryRobotsGame; 9 | 10 | public class VeryAngryRobotsActivity extends AndroidApplication { 11 | /** Called when the activity is first created. */ 12 | @Override 13 | public void onCreate (Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 16 | config.useCompass = false; 17 | config.useAccelerometer = false; 18 | VeryAngryRobotsGame game = new VeryAngryRobotsGame(); 19 | initialize(game, config); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/FlyupManager.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots; 3 | 4 | import com.badlogic.gdx.utils.Array; 5 | 6 | public class FlyupManager implements ScoringEventListener { 7 | 8 | private static final int MAX_FLYUPS = 16; 9 | 10 | final Array flyups; 11 | private int index; 12 | 13 | public FlyupManager () { 14 | flyups = new Array(MAX_FLYUPS); 15 | for (int i = 0; i < MAX_FLYUPS; i++) { 16 | flyups.add(new Flyup()); 17 | } 18 | index = 0; 19 | } 20 | 21 | @Override 22 | public void onScoringEvent (float x, float y, int points) { 23 | flyups.get(index).spawn(x, y, points); 24 | if (++index == MAX_FLYUPS) { 25 | index = 0; 26 | } 27 | } 28 | 29 | public void update (float delta) { 30 | for (Flyup flyup : flyups) { 31 | if (flyup.active) { 32 | flyup.update(delta); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/AchievementsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlydrawngames.veryangryrobots.StatusManager.Achievements; 17 | 18 | public interface AchievementsListener { 19 | void onAttained (Achievements achievement); 20 | } 21 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/DifficultyManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | 18 | public interface DifficultyManager { 19 | Color getRobotColor (); 20 | 21 | int getNumberOfRobots (); 22 | 23 | int getNumberOfRobotShots (); 24 | 25 | float getRobotShotSpeed (); 26 | } 27 | -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | very-angry-robots-android 4 | 5 | 6 | Very Angry Robots - Desktop 7 | 8 | 9 | 10 | com.android.ide.eclipse.adt.ResourceManagerBuilder 11 | 12 | 13 | 14 | 15 | com.android.ide.eclipse.adt.PreCompilerBuilder 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javabuilder 21 | 22 | 23 | 24 | 25 | com.android.ide.eclipse.adt.ApkBuilder 26 | 27 | 28 | 29 | 30 | 31 | com.android.ide.eclipse.adt.AndroidNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/DoorPositions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | public final class DoorPositions { 17 | public static final int NONE = 0x00; 18 | public static final int MIN_X = 0x01; 19 | public static final int MAX_X = 0x02; 20 | public static final int MIN_Y = 0x04; 21 | public static final int MAX_Y = 0x08; 22 | public static final int ALL = 0x0f; 23 | } 24 | -------------------------------------------------------------------------------- /desktop/src/com/badlydrawngames/veryangryrobots/DesktopStarter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication; 17 | 18 | public class DesktopStarter { 19 | 20 | private final static int WINDOW_WIDTH = 800; 21 | private final static int WINDOW_HEIGHT = 480; 22 | 23 | public static void main (String[] args) { 24 | new LwjglApplication(new VeryAngryRobotsGame(), "Very Angry Robots", WINDOW_WIDTH, WINDOW_HEIGHT); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/Flyup.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlydrawngames.veryangryrobots; 3 | 4 | import com.badlydrawngames.general.Config; 5 | import com.badlydrawngames.general.ScoreString; 6 | 7 | public class Flyup { 8 | 9 | private static final float LIFE_TIME = Config.asFloat("flyup.lifetime", 1.0f); 10 | private static final float X_OFFSET = (Assets.flyupFont.getBounds("888").width / 2) / Assets.pixelDensity; 11 | private static final float Y_OFFSET = (Assets.flyupFont.getBounds("888").height) / Assets.pixelDensity; 12 | private static final float SPEED = Config.asFloat("flyup.speed", 25.0f); 13 | 14 | public final ScoreString scoreString; 15 | public boolean active; 16 | public float x; 17 | public float y; 18 | private float stateTime; 19 | 20 | public Flyup () { 21 | scoreString = new ScoreString(3); 22 | } 23 | 24 | public void update (float delta) { 25 | stateTime += delta; 26 | active = stateTime < LIFE_TIME; 27 | y += SPEED * delta; 28 | } 29 | 30 | public void spawn (float x, float y, int points) { 31 | active = true; 32 | stateTime = 0.0f; 33 | scoreString.setScore(points); 34 | this.x = x - X_OFFSET; 35 | this.y = y + Y_OFFSET; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /android/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembernames class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembernames class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers enum * { 30 | public static **[] values(); 31 | public static ** valueOf(java.lang.String); 32 | } 33 | 34 | -keep class * implements android.os.Parcelable { 35 | public static final android.os.Parcelable$Creator *; 36 | } 37 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/GameScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.Screen; 17 | 18 | public class GameScreen implements Screen { 19 | protected T game; 20 | 21 | public GameScreen (T game) { 22 | this.game = game; 23 | } 24 | 25 | @Override 26 | public void dispose () { 27 | } 28 | 29 | @Override 30 | public void hide () { 31 | } 32 | 33 | @Override 34 | public void pause () { 35 | } 36 | 37 | @Override 38 | public void render (float delta) { 39 | } 40 | 41 | @Override 42 | public void resize (int width, int height) { 43 | } 44 | 45 | @Override 46 | public void resume () { 47 | } 48 | 49 | @Override 50 | public void show () { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/BaseShot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | public class BaseShot extends GameObject { 17 | 18 | private float dx; 19 | private float dy; 20 | private float shotSpeed; 21 | 22 | public BaseShot () { 23 | super(); 24 | } 25 | 26 | public void setShotSpeed (float shotSpeed) { 27 | this.shotSpeed = shotSpeed; 28 | } 29 | 30 | public void fire (float x, float y, float dx, float dy) { 31 | this.x = x; 32 | this.y = y; 33 | this.dx = dx; 34 | this.dy = dy; 35 | } 36 | 37 | @Override 38 | public void update (float delta) { 39 | stateTime += delta; 40 | float n = shotSpeed * delta; 41 | x += dx * n; 42 | y += dy * n; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/MathUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | public class MathUtils { 17 | public static float abs (float n) { 18 | return (n >= 0.0f) ? n : -n; 19 | } 20 | 21 | public static float sgn (float n) { 22 | if (n > 0.0f) 23 | return 1.0f; 24 | else if (n < 0.0f) 25 | return -1.0f; 26 | else 27 | return 0.0f; 28 | } 29 | 30 | public static float min (float a, float b) { 31 | return (a < b) ? a : b; 32 | } 33 | 34 | public static float max (float a, float b) { 35 | return (a > b) ? a : b; 36 | } 37 | 38 | public static int min (int a, int b) { 39 | return (a < b) ? a : b; 40 | } 41 | 42 | public static int max (int a, int b) { 43 | return (a > b) ? a : b; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Rectangles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | 18 | import static com.badlydrawngames.general.MathUtils.*; 19 | 20 | public class Rectangles { 21 | 22 | private Rectangles () { 23 | } 24 | 25 | public static void setRectangle (Rectangle r, float x, float y, float w, float h) { 26 | r.x = x; 27 | r.y = y; 28 | r.width = w; 29 | r.height = h; 30 | } 31 | 32 | public static Rectangle union (Rectangle a, Rectangle b, Rectangle result) { 33 | result.x = min(a.x, b.x); 34 | result.y = min(a.y, b.y); 35 | result.width = max(a.x + a.width, b.x + b.width) - result.x; 36 | result.height = max(a.y + a.height, b.y + b.height) - result.y; 37 | return result; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/AchievementsNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | import com.badlydrawngames.veryangryrobots.StatusManager.Achievements; 18 | 19 | public class AchievementsNotifier implements AchievementsListener { 20 | 21 | private final Array listeners; 22 | 23 | public AchievementsNotifier () { 24 | this.listeners = new Array(); 25 | } 26 | 27 | public void addListener (AchievementsListener listener) { 28 | listeners.add(listener); 29 | } 30 | 31 | @Override 32 | public void onAttained (Achievements achievement) { 33 | for (AchievementsListener listener : listeners) { 34 | listener.onAttained(achievement); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoreNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | 18 | public class ScoreNotifier implements ScoreListener { 19 | 20 | private Array listeners; 21 | 22 | public ScoreNotifier () { 23 | listeners = new Array(); 24 | } 25 | 26 | public void addListener (ScoreListener listener) { 27 | listeners.add(listener); 28 | } 29 | 30 | @Override 31 | public void onScoreChanged (int score) { 32 | for (ScoreListener listener : listeners) { 33 | listener.onScoreChanged(score); 34 | } 35 | } 36 | 37 | @Override 38 | public void onLivesChanged (int lives) { 39 | for (ScoreListener listener : listeners) { 40 | listener.onLivesChanged(lives); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/RobotShot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | import com.badlydrawngames.general.Config; 17 | import com.badlydrawngames.veryangryrobots.Assets; 18 | 19 | public class RobotShot extends BaseShot { 20 | 21 | private static final float DEFAULT_SHOT_SPEED = Config.asFloat("RobotShot.slowSpeed", 4.6875f); 22 | 23 | private GameObject owner; 24 | 25 | public RobotShot () { 26 | width = Assets.robotShotWidth; 27 | height = Assets.robotShotHeight; 28 | setShotSpeed(DEFAULT_SHOT_SPEED); 29 | } 30 | 31 | public void setOwner (GameObject owner) { 32 | this.owner = owner; 33 | } 34 | 35 | @Override 36 | public boolean intersects (GameObject other) { 37 | return (owner != other) && super.intersects(other); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/WorldListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlydrawngames.veryangryrobots.mobiles.BaseShot; 17 | import com.badlydrawngames.veryangryrobots.mobiles.Robot; 18 | 19 | public interface WorldListener { 20 | public void onCaptainActivated (float time); 21 | 22 | public void onEnteredRoom (float time, int robots); 23 | 24 | public void onExitedRoom (float time, int robots); 25 | 26 | public void onPlayerFired (); 27 | 28 | public void onPlayerHit (); 29 | 30 | public void onPlayerSpawned (); 31 | 32 | public void onRobotDestroyed (Robot robot); 33 | 34 | public void onRobotFired (Robot robot); 35 | 36 | public void onRobotHit (Robot robot); 37 | 38 | public void onShotDestroyed (BaseShot shot); 39 | 40 | public void onWorldReset (); 41 | } 42 | -------------------------------------------------------------------------------- /desktop/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "java" 2 | 3 | sourceCompatibility = 1.6 4 | sourceSets.main.java.srcDirs = [ "src/" ] 5 | 6 | project.ext.mainClassName = "com.badlydrawngames.veryangryrobots.DesktopStarter" 7 | project.ext.assetsDir = new File("../android/assets"); 8 | 9 | task run(dependsOn: classes, type: JavaExec) { 10 | main = project.mainClassName 11 | classpath = sourceSets.main.runtimeClasspath 12 | standardInput = System.in 13 | workingDir = project.assetsDir 14 | ignoreExitValue = true 15 | } 16 | 17 | task dist(type: Jar) { 18 | from files(sourceSets.main.output.classesDir) 19 | from files(sourceSets.main.output.resourcesDir) 20 | from {configurations.compile.collect {zipTree(it)}} 21 | from files(project.assetsDir); 22 | 23 | manifest { 24 | attributes 'Main-Class': project.mainClassName 25 | } 26 | } 27 | 28 | dist.dependsOn classes 29 | 30 | 31 | eclipse { 32 | project { 33 | name = appName + "-desktop" 34 | linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets' 35 | } 36 | } 37 | 38 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") { 39 | doLast { 40 | def classpath = new XmlParser().parse(file(".classpath")) 41 | new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]); 42 | def writer = new FileWriter(file(".classpath")) 43 | def printer = new XmlNodePrinter(new PrintWriter(writer)) 44 | printer.setPreserveWhitespace(true) 45 | printer.print(classpath) 46 | } 47 | } -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/ParticleManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | import com.badlogic.gdx.utils.Array; 18 | 19 | public class ParticleManager { 20 | 21 | private final Array particles; 22 | private final int maxParticles; 23 | private int index; 24 | 25 | public ParticleManager (int maxParticles, float size) { 26 | particles = new Array(maxParticles); 27 | this.maxParticles = maxParticles; 28 | for (int i = 0; i < maxParticles; i++) { 29 | particles.add(new Particle(size)); 30 | } 31 | index = 0; 32 | } 33 | 34 | public Array getParticles () { 35 | return particles; 36 | } 37 | 38 | public void clear () { 39 | for (Particle particle : particles) { 40 | particle.active = false; 41 | } 42 | } 43 | 44 | public void add (float x, float y, int n, Color c) { 45 | for (int i = 0; i < n; i++) { 46 | particles.get(index).spawn(c, x, y); 47 | if (++index == maxParticles) { 48 | index = 0; 49 | } 50 | } 51 | } 52 | 53 | public void update (float delta) { 54 | for (Particle particle : particles) { 55 | if (particle.active) { 56 | particle.update(delta); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Java 2 | 3 | *.class 4 | *.jar 5 | *.war 6 | *.ear 7 | hs_err_pid* 8 | 9 | ## GWT 10 | 11 | war/gwt_bree/ 12 | gwt-unitCache/ 13 | .apt_generated/ 14 | war/WEB-INF/deploy/ 15 | war/WEB-INF/classes/ 16 | .gwt/ 17 | gwt-unitCache/ 18 | www-test/ 19 | .gwt-tmp/ 20 | 21 | ## Android Studio and Intellij 22 | libs/armeabi/ 23 | libs/armeabi-v7a/ 24 | libs/x86/ 25 | gen/ 26 | .idea/ 27 | *.ipr 28 | *.iws 29 | *.iml 30 | out/ 31 | com_crashlytics_export_strings.xml 32 | 33 | ## Eclipse 34 | 35 | .metadata 36 | bin/ 37 | tmp/ 38 | *.tmp 39 | *.bak 40 | *.swp 41 | *~.nib 42 | local.properties 43 | .settings/ 44 | .loadpath 45 | .externalToolBuilders/ 46 | *.launch 47 | 48 | ## NetBeans 49 | nbproject/private/ 50 | build/ 51 | nbbuild/ 52 | dist/ 53 | nbdist/ 54 | nbactions.xml 55 | nb-configuration.xml 56 | 57 | ## Gradle 58 | 59 | .gradle 60 | build/ 61 | 62 | 63 | # Temporary Files 64 | *~ 65 | .*.swp 66 | .DS_STORE 67 | 68 | bin/ 69 | target/ 70 | obj/ 71 | .gwt/ 72 | gwt-unitCache/ 73 | war/ 74 | gen/ 75 | armeabi/ 76 | armeabi-v7a/ 77 | linux32/ 78 | linux64/ 79 | windows32/ 80 | windows64/ 81 | macosx32/ 82 | ios32/ 83 | Debug/ 84 | Release/ 85 | x64/ 86 | x86/ 87 | ipch/ 88 | /dist 89 | 90 | *.a 91 | *.dll 92 | *.dll.mdb 93 | *.userprefs 94 | *.sdf 95 | *.class 96 | 97 | libgdx-*.zip 98 | libgdx-*.zip.MD5 99 | 100 | *.iml 101 | /.idea/ 102 | 103 | #core & extension libs/ folders that have no 3rd party dependencies in them 104 | /gdx/libs 105 | /backends/gdx-backend-jglfw/libs/ 106 | /backends/gdx-backend-robovm/libs/ 107 | /extensions/gdx-audio/libs/ 108 | /extensions/gdx-bullet/libs/ 109 | /extensions/gdx-controllers/gdx-controllers-desktop/libs/ 110 | /extensions/gdx-freetype/libs/ 111 | /extensions/gdx-image/libs/ 112 | 113 | #ensure gdx-setup.jar works properly 114 | !/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/gwt/war 115 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Pools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | import com.badlogic.gdx.utils.Pool; 18 | 19 | /** Pool helper functions. 20 | * @author Rod */ 21 | public class Pools { 22 | private Pools () { 23 | }; 24 | 25 | /** Frees the items in an array to a pool. 26 | * @param the type of item allocated in the array. 27 | * @param array the array of items to free. 28 | * @param pool the pool that the items are to be released to. */ 29 | public static void freeArrayToPool (Array array, Pool pool) { 30 | pool.freeAll(array); 31 | array.clear(); 32 | } 33 | 34 | /** Creates an array from a pool, freeing its items if it already exists. 35 | * @param the type of item allocated in the array. 36 | * @param array the array of items to (re)create. 37 | * @param pool the pool that the items are to be allocated from / released to. 38 | * @param size the array's capacity. 39 | * @return the input array */ 40 | @SuppressWarnings("unchecked") 41 | public static Array makeArrayFromPool (Array array, Pool pool, int size) { 42 | if (array == null) { 43 | // Do this so that array.items can be used. 44 | T t = pool.obtain(); 45 | array = new Array(false, size, (Class)t.getClass()); 46 | pool.free(t); 47 | } else { 48 | freeArrayToPool(array, pool); 49 | } 50 | return array; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/Player.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | import com.badlydrawngames.general.Config; 17 | import com.badlydrawngames.veryangryrobots.Assets; 18 | 19 | public class Player extends GameObject { 20 | 21 | public static final int STANDING = INACTIVE + 1; 22 | public static final int WALKING_LEFT = STANDING + 1; 23 | public static final int WALKING_RIGHT = WALKING_LEFT + 1; 24 | public static final int FACING_LEFT = WALKING_RIGHT + 1; 25 | public static final int FACING_RIGHT = FACING_LEFT + 1; 26 | 27 | private static final float SPEED = Config.asFloat("Player.speed", 12.5f); 28 | 29 | private float dx; 30 | private float dy; 31 | 32 | public Player () { 33 | width = Assets.playerWidth; 34 | height = Assets.playerHeight; 35 | geometry = Assets.playerGeometry; 36 | } 37 | 38 | @Override 39 | public void update (float delta) { 40 | if (dx > 0.0f) { 41 | if (state != WALKING_RIGHT) { 42 | setState(WALKING_RIGHT); 43 | } 44 | } else if (dx < 0.0f) { 45 | if (state != WALKING_LEFT) { 46 | setState(WALKING_LEFT); 47 | } 48 | } else if (state == WALKING_RIGHT) { 49 | setState(FACING_RIGHT); 50 | } else if (state == WALKING_LEFT) { 51 | setState(FACING_LEFT); 52 | } 53 | stateTime += delta; 54 | float d = delta * SPEED; 55 | x += dx * d; 56 | y += dy * d; 57 | } 58 | 59 | public void setController (float x, float y) { 60 | dx = x; 61 | dy = y; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/ScoreString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | /** A ScoreString exists to prevent calls to {@link String#format(String, Object...)} as this seems to be rather 17 | * profligate at allocating memory, which in turns leads to garbage collection. Given that we can't manage that directly we do our 18 | * own thing. 19 | * 20 | * @author Rod */ 21 | public class ScoreString implements CharSequence { 22 | 23 | public static final int DEFAULT_CHARS = 6; 24 | 25 | private final char[] score; 26 | private final int start; 27 | 28 | public ScoreString () { 29 | this(DEFAULT_CHARS); 30 | } 31 | 32 | public ScoreString (int numChars) { 33 | score = new char[numChars]; 34 | int n = 1; 35 | for (int i = 0; i < numChars - 1; i++) { 36 | n *= 10; 37 | } 38 | start = n; 39 | } 40 | 41 | @Override 42 | public char charAt (int index) { 43 | return score[index]; 44 | } 45 | 46 | @Override 47 | public int length () { 48 | return score.length; 49 | } 50 | 51 | @Override 52 | public CharSequence subSequence (int start, int end) { 53 | // Don't care. Call at your own risk. 54 | return null; 55 | } 56 | 57 | /** Sets this ScoreString to hold the given integer value. 58 | * 59 | * @param v the value that the ScoreString will hold. */ 60 | public void setScore (int v) { 61 | for (int n = start, i = 0; i < score.length; n /= 10, i++) { 62 | int j = (v / n) % 10; 63 | score[i] = (char)('0' + j); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Particle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | 18 | import static com.badlogic.gdx.math.MathUtils.*; 19 | import static com.badlydrawngames.general.MathUtils.*; 20 | 21 | public class Particle { 22 | 23 | private final float MIN_SPEED = 3.125f; 24 | private final float MAX_SPEED = 6.25f; 25 | private final float DECAY = 2.0f; 26 | 27 | public boolean active; 28 | public float x; 29 | public float y; 30 | public Color color; 31 | public final float size; 32 | final float halfSize; 33 | float dx; 34 | float dy; 35 | float r; 36 | float g; 37 | float b; 38 | float a; 39 | 40 | public Particle (float size) { 41 | this.color = new Color(); 42 | this.size = size; 43 | this.halfSize = size / 2; 44 | } 45 | 46 | public void spawn (Color c, float x, float y) { 47 | this.active = true; 48 | this.x = x - halfSize; 49 | this.y = y - halfSize; 50 | color.set(c); 51 | r = c.r; 52 | g = c.g; 53 | b = c.b; 54 | a = 3.0f; 55 | float direction = random((float)-PI, PI); 56 | float speed = random(MIN_SPEED, MAX_SPEED); 57 | dx = cos(direction) * speed; 58 | dy = sin(direction) * speed; 59 | } 60 | 61 | public void update (float delta) { 62 | x += dx * delta; 63 | y += dy * delta; 64 | dx *= (1.0 - DECAY * delta * 0.5f); 65 | dy *= (1.0 - DECAY * delta * 0.5f); 66 | a *= (1.0 - DECAY * delta); 67 | color.a = min(1.0f, a); 68 | color.r = min(1.0f, r + max(0, (a - 1.0f))); 69 | color.g = min(1.0f, g + max(0, (a - 1.0f))); 70 | color.b = min(1.0f, b + max(0, (a - 1.0f))); 71 | active = active && a > 0.1f; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.util.Properties; 19 | 20 | import com.badlogic.gdx.Gdx; 21 | import com.badlogic.gdx.files.FileHandle; 22 | 23 | /** Provides a simple way to tweak the game configuration via attributes. Ideally this would be backed with a 24 | * ConfigProvider or similar. 25 | * @author Rod */ 26 | public class Config { 27 | 28 | private static final String PROPERTIES_FILE = "data/veryangryrobots.properties"; 29 | private static Properties properties; 30 | 31 | private Config () { 32 | } 33 | 34 | private static Properties instance () { 35 | if (null == properties) { 36 | properties = new Properties(); 37 | FileHandle fh = Gdx.files.internal(PROPERTIES_FILE); 38 | InputStream inStream = fh.read(); 39 | try { 40 | properties.load(inStream); 41 | inStream.close(); 42 | } catch (IOException e) { 43 | if (inStream != null) { 44 | try { 45 | inStream.close(); 46 | } catch (IOException ex) { 47 | } 48 | } 49 | } 50 | } 51 | return properties; 52 | } 53 | 54 | public static int asInt (String name, int fallback) { 55 | String v = instance().getProperty(name); 56 | if (v == null) return fallback; 57 | return Integer.parseInt(v); 58 | } 59 | 60 | public static float asFloat (String name, float fallback) { 61 | String v = instance().getProperty(name); 62 | if (v == null) return fallback; 63 | return Float.parseFloat(v); 64 | } 65 | 66 | public static String asString (String name, String fallback) { 67 | String v = instance().getProperty(name); 68 | if (v == null) return fallback; 69 | return v; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/VeryAngryRobotsGame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.Game; 17 | import com.badlogic.gdx.Screen; 18 | import com.badlydrawngames.veryangryrobots.StatusManager.Achievements; 19 | 20 | public class VeryAngryRobotsGame extends Game implements AchievementsListener { 21 | 22 | Screen mainMenuScreen; 23 | Screen playingScreen; 24 | ScoresScreen scoresScreen; 25 | IShowScores scoreDisplayer; 26 | ISubmitScores scoreSubmitter; 27 | AchievementsListener achievementsListener; 28 | 29 | /** Creates all the screens that the game will need, then switches to the main menu. */ 30 | @Override 31 | public void create () { 32 | Assets.load(); 33 | mainMenuScreen = new MainMenuScreen(this); 34 | playingScreen = new WorldPresenter(this); 35 | scoresScreen = new ScoresScreen(this); 36 | setScreen(mainMenuScreen); 37 | } 38 | 39 | public void submitScore (int score) { 40 | if (scoreSubmitter != null) { 41 | scoreSubmitter.submitScore(score); 42 | } 43 | } 44 | 45 | public void showScores () { 46 | if (scoreDisplayer != null) { 47 | scoreDisplayer.showScores(); 48 | } 49 | } 50 | 51 | @Override 52 | public void onAttained (Achievements achievement) { 53 | if (achievementsListener != null) { 54 | achievementsListener.onAttained(achievement); 55 | } 56 | } 57 | 58 | public void setScoreDisplayer (IShowScores scoreDisplayer) { 59 | this.scoreDisplayer = scoreDisplayer; 60 | } 61 | 62 | public void setScoreSubmitter (ISubmitScores scoreSubmitter) { 63 | this.scoreSubmitter = scoreSubmitter; 64 | } 65 | 66 | public void setAchievementsListener (AchievementsListener listener) { 67 | this.achievementsListener = listener; 68 | } 69 | 70 | public boolean canShowScores () { 71 | return scoreDisplayer != null; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/Captain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | import com.badlydrawngames.general.Config; 17 | import com.badlydrawngames.veryangryrobots.Assets; 18 | 19 | import static com.badlogic.gdx.math.MathUtils.*; 20 | 21 | public class Captain extends GameObject { 22 | 23 | public static final int LURKING = INACTIVE + 1; 24 | public static final int CHASING = LURKING + 1; 25 | 26 | private static final float SPEED = Config.asFloat("Captain.speed", 3.75f); 27 | private static final float BOUNCE_SIZE = Config.asFloat("Captain.bounceSize", 5.625f); 28 | private static final float BOUNCE_FREQUENCY = Config.asFloat("Captain.bounceFrequency", 10.0f); 29 | 30 | private float activateTime; 31 | private Player player; 32 | private float speed; 33 | private float t; 34 | 35 | public Captain () { 36 | width = Assets.captainWidth; 37 | height = Assets.captainHeight; 38 | geometry = Assets.captainGeometry; 39 | setState(INACTIVE); 40 | speed = SPEED; 41 | } 42 | 43 | @Override 44 | public void update (float delta) { 45 | stateTime += delta; 46 | if (state == LURKING) { 47 | updateLurking(delta); 48 | } else if (state == CHASING) { 49 | updateChasing(delta); 50 | } 51 | } 52 | 53 | public void activateAfter (float interval) { 54 | activateTime = stateTime + interval; 55 | } 56 | 57 | public void setPlayer (Player player) { 58 | this.player = player; 59 | } 60 | 61 | private void updateLurking (float delta) { 62 | if (stateTime >= activateTime) { 63 | setState(Captain.CHASING); 64 | } 65 | } 66 | 67 | private void updateChasing (float delta) { 68 | float dx = player.x - x; 69 | float dy = player.y - y; 70 | float angle = atan2(dy, dx); 71 | float sd = speed * delta; 72 | x += cos(angle) * sd; 73 | y += sin(angle) * sd; 74 | if (sin(t) > 0) { 75 | y += BOUNCE_SIZE * delta; 76 | } else { 77 | y -= BOUNCE_SIZE * delta; 78 | } 79 | t += delta * BOUNCE_FREQUENCY; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /core/data/veryangryrobots.properties: -------------------------------------------------------------------------------- 1 | # Game window dimensions in virtual coordinates. 2 | Global.screenWidth = 480 3 | Global.screenHeight = 320 4 | Global.statusAreaHeight = 24 5 | 6 | # Fonts. 7 | Global.scoreFont = wellbutrin.fnt 8 | Global.flyupFont = ocr_a_small.fnt 9 | Global.textFont = ocr_a.fnt 10 | 11 | # Robot numbers. 12 | Global.initialRobots = 6 13 | Global.maxRobots = 12 14 | 15 | # Timings. 16 | Global.deadTime = 2.0 17 | Global.amnestyTime = 2.0 18 | Global.roomTransitionTime = 0.333 19 | 20 | # Level progression. 21 | Level.robotIncrement = 3 22 | Level.0.robotShots = 0 23 | Level.0.score = 0 24 | Level.1.robotShots = 1 25 | Level.1.score = 300 26 | Level.2.robotShots = 2 27 | Level.2.score = 1000 28 | Level.3.robotShots = 3 29 | Level.3.score = 2000 30 | Level.4.robotShots = 4 31 | Level.4.score = 4000 32 | Level.5.robotShots = 5 33 | Level.5.score = 5000 34 | Level.6.robotShots = 1 35 | Level.6.score = 6000 36 | Level.7.robotShots = 2 37 | Level.7.score = 8000 38 | Level.8.robotShots = 3 39 | Level.8.score = 10000 40 | Level.9.robotShots = 4 41 | Level.9.score = 12500 42 | Level.10.robotShots = 5 43 | Level.10.score = 15000 44 | Level.11.robotShots = 6 45 | Level.11.score = 20000 46 | 47 | # Player attributes. 48 | Player.borderWidthPercent = 25.0 49 | Player.borderHeightPercent = 6.7 50 | Player.frameDuration = 0.2 51 | Player.speed = 12.5 52 | Player.maxShots = 4 53 | Player.lives = 3 54 | Player.firingInterval = 0.25 55 | Player.firstExtraLife = 10000 56 | Player.secondExtraLife = 50000 57 | 58 | # Captain attributes. 59 | Captain.borderWidthPercent = 16.7 60 | Captain.borderHeightPercent = 16.7 61 | Captain.frameDuration = 0.5 62 | Captain.speed = 3.75 63 | Captain.bounceSize = 5.625 64 | Captain.bounceFrequency = 10.0 65 | Captain.minLurkTime = 2.0 66 | Captain.lurkMultiplier = 2.0 67 | 68 | # Robot attributes. 69 | Robot.frameDuration = 0.1 70 | Robot.speed = 1.25 71 | Robot.maxShots = 6 72 | Robot.score = 50 73 | Robot.bonusScore = 100 74 | 75 | # PlayerShot attributes. 76 | PlayerShot.speed = 31.25 77 | 78 | # RobotShot attributes. 79 | RobotShot.slowSpeed = 4.6875 80 | RobotShot.fastSpeed = 6.0 81 | 82 | # Maze attributes. 83 | Maze.hCells = 5 84 | Maze.vCells = 3 85 | 86 | # Achievements. 87 | achievements.cleanRoomsForPerfectionist = 10 88 | achievements.robotsForRobocide = 50 89 | achievements.roomsForLuckyJim = 10 90 | achievements.roomsForChicken = 5 91 | achievements.gamesForAddict = 10 92 | achievements.daredevilSeconds = 10 93 | 94 | # Status display. 95 | status.achievementDisplayTime = 5.0 96 | status.achievementFlashCycleLength = 0.5 97 | status.achievementFlashOnPercent = 50 98 | 99 | # Flyups. 100 | flyup.lifetime = 1.0 101 | flyup.speed = 1.5625 102 | 103 | # Particles. 104 | particle.size = 0.1875 105 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Grid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | import com.badlogic.gdx.utils.Array; 18 | 19 | import static com.badlydrawngames.general.MathUtils.*; 20 | 21 | public class Grid { 22 | 23 | private final int cols; 24 | private final int rows; 25 | private final float cellWidth; 26 | private final float cellHeight; 27 | private final Array> grid; 28 | private Array result; 29 | 30 | public Grid (int cols, int rows, float width, float height) { 31 | this.cols = cols; 32 | this.rows = rows; 33 | this.cellWidth = width / cols; 34 | this.cellHeight = height / rows; 35 | this.grid = new Array>(cols * rows); 36 | for (int i = 0; i < cols * rows; i++) { 37 | grid.add(new Array()); 38 | } 39 | this.result = new Array(); 40 | } 41 | 42 | public void clear () { 43 | for (Array v : grid) { 44 | v.clear(); 45 | } 46 | } 47 | 48 | public void add (Rectangle r) { 49 | int minX = max(0, cellX(r.x)); 50 | int maxX = min(cols - 1, cellX(r.x + r.width)); 51 | int minY = max(0, cellY(r.y)); 52 | int maxY = min(rows - 1, cellY(r.y + r.height)); 53 | for (int y = minY; y <= maxY; y++) { 54 | for (int x = minX; x <= maxX; x++) { 55 | int shv = getGridCell(x, y); 56 | Array values = grid.get(shv); 57 | values.add(r); 58 | } 59 | } 60 | } 61 | 62 | public Array get (Rectangle r) { 63 | result.clear(); 64 | int minX = max(0, cellX(r.x)); 65 | int maxX = min(cols - 1, cellX(r.x + r.width)); 66 | int minY = max(0, cellY(r.y)); 67 | int maxY = min(rows - 1, cellY(r.y + r.height)); 68 | for (int y = minY; y <= maxY; y++) { 69 | for (int x = minX; x <= maxX; x++) { 70 | int shv = getGridCell(x, y); 71 | result.addAll(grid.get(shv)); 72 | } 73 | } 74 | return result; 75 | } 76 | 77 | private int cellX (float x) { 78 | return (int)(x / cellWidth); 79 | } 80 | 81 | private int cellY (float y) { 82 | return (int)(y / cellHeight); 83 | } 84 | 85 | private int getGridCell (int x, int y) { 86 | return x + y * cols; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/CollisionGeometry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | import com.badlogic.gdx.utils.Array; 18 | 19 | import static com.badlydrawngames.general.Rectangles.*; 20 | 21 | public class CollisionGeometry { 22 | private final Array runs; 23 | private final Rectangle r; 24 | 25 | /** Creates this collision geometry. 26 | * @param runs the model-space rectangles that make up this object's collision geometry. */ 27 | public CollisionGeometry (Array runs) { 28 | this.runs = runs; 29 | r = new Rectangle(); 30 | } 31 | 32 | /** Tests if this collision geometry would collide with a rectangle if it was at the given coordinates. 33 | * @param other the rectangle to test against. 34 | * @param x the x coordinate of this collision geometry. 35 | * @param y the y coordinate of this collision geometry. 36 | * @return true if in collision otherwise false. */ 37 | public boolean intersects (Rectangle other, float x, float y) { 38 | boolean result = false; 39 | for (int i = 0; i < runs.size; i++) { 40 | Rectangle run = runs.get(i); 41 | setRectangle(r, x + run.x, y + run.y, run.width, run.height); 42 | if (Colliders.intersects(r, other)) { 43 | result = true; 44 | break; 45 | } 46 | } 47 | return result; 48 | } 49 | 50 | /** Tests if this collision geometry is in collision with another. 51 | * @param x this collision geometry's x coordinate. 52 | * @param y this collision geometry's y coordinate. 53 | * @param other the other collision geometry. 54 | * @param otherX the other collision geometry's x coordinate. 55 | * @param otherY the other collision geometry's y coordinate. 56 | * @return true if in collision otherwise false. */ 57 | public boolean intersects (float x, float y, CollisionGeometry other, float otherX, float otherY) { 58 | boolean result = false; 59 | for (int i = 0; i < runs.size; i++) { 60 | Rectangle run = runs.get(i); 61 | setRectangle(r, x + run.x, y + run.y, run.width, run.height); 62 | if (other.intersects(r, otherX, otherY)) { 63 | result = true; 64 | break; 65 | } 66 | } 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/data/textures/16/pack: -------------------------------------------------------------------------------- 1 | 2 | png1.png 3 | format: RGBA8888 4 | filter: Nearest,Nearest 5 | repeat: none 6 | BigBadGuy2 7 | rotate: false 8 | xy: 0, 0 9 | size: 33, 32 10 | orig: 33, 32 11 | offset: 0, 0 12 | index: -1 13 | BigBadGuy1 14 | rotate: false 15 | xy: 35, 0 16 | size: 33, 32 17 | orig: 33, 32 18 | offset: 0, 0 19 | index: -1 20 | pause 21 | rotate: false 22 | xy: 70, 0 23 | size: 30, 30 24 | orig: 30, 30 25 | offset: 0, 0 26 | index: -1 27 | HeroRight2 28 | rotate: false 29 | xy: 102, 0 30 | size: 20, 30 31 | orig: 20, 30 32 | offset: 0, 0 33 | index: -1 34 | HeroRight1 35 | rotate: false 36 | xy: 124, 0 37 | size: 20, 30 38 | orig: 20, 30 39 | offset: 0, 0 40 | index: -1 41 | HeroLeft2 42 | rotate: false 43 | xy: 146, 0 44 | size: 20, 30 45 | orig: 20, 30 46 | offset: 0, 0 47 | index: -1 48 | HeroLeft1 49 | rotate: false 50 | xy: 168, 0 51 | size: 20, 30 52 | orig: 20, 30 53 | offset: 0, 0 54 | index: -1 55 | RobotScan3 56 | rotate: false 57 | xy: 190, 0 58 | size: 18, 30 59 | orig: 18, 30 60 | offset: 0, 0 61 | index: -1 62 | RobotScan2 63 | rotate: false 64 | xy: 210, 0 65 | size: 18, 30 66 | orig: 18, 30 67 | offset: 0, 0 68 | index: -1 69 | RobotScan1 70 | rotate: false 71 | xy: 230, 0 72 | size: 18, 30 73 | orig: 18, 30 74 | offset: 0, 0 75 | index: -1 76 | RobotScan0 77 | rotate: false 78 | xy: 250, 0 79 | size: 18, 30 80 | orig: 18, 30 81 | offset: 0, 0 82 | index: -1 83 | RobotRight3 84 | rotate: false 85 | xy: 270, 0 86 | size: 18, 30 87 | orig: 18, 30 88 | offset: 0, 0 89 | index: -1 90 | RobotRight2 91 | rotate: false 92 | xy: 290, 0 93 | size: 18, 30 94 | orig: 18, 30 95 | offset: 0, 0 96 | index: -1 97 | RobotRight1 98 | rotate: false 99 | xy: 310, 0 100 | size: 18, 30 101 | orig: 18, 30 102 | offset: 0, 0 103 | index: -1 104 | RobotRight0 105 | rotate: false 106 | xy: 330, 0 107 | size: 18, 30 108 | orig: 18, 30 109 | offset: 0, 0 110 | index: -1 111 | RobotLeft3 112 | rotate: false 113 | xy: 350, 0 114 | size: 18, 30 115 | orig: 18, 30 116 | offset: 0, 0 117 | index: -1 118 | RobotLeft2 119 | rotate: false 120 | xy: 370, 0 121 | size: 18, 30 122 | orig: 18, 30 123 | offset: 0, 0 124 | index: -1 125 | RobotLeft1 126 | rotate: false 127 | xy: 390, 0 128 | size: 18, 30 129 | orig: 18, 30 130 | offset: 0, 0 131 | index: -1 132 | RobotLeft0 133 | rotate: false 134 | xy: 410, 0 135 | size: 18, 30 136 | orig: 18, 30 137 | offset: 0, 0 138 | index: -1 139 | 8x8 140 | rotate: false 141 | xy: 430, 0 142 | size: 8, 8 143 | orig: 8, 8 144 | offset: 0, 0 145 | index: -1 146 | RobotShot01 147 | rotate: false 148 | xy: 430, 10 149 | size: 6, 6 150 | orig: 6, 6 151 | offset: 0, 0 152 | index: -1 153 | PlayerShot01 154 | rotate: false 155 | xy: 430, 18 156 | size: 6, 6 157 | orig: 6, 6 158 | offset: 0, 0 159 | index: -1 160 | -------------------------------------------------------------------------------- /core/data/textures/24/pack: -------------------------------------------------------------------------------- 1 | 2 | png1.png 3 | format: RGBA8888 4 | filter: Nearest,Nearest 5 | repeat: none 6 | BigBadGuy2 7 | rotate: false 8 | xy: 0, 0 9 | size: 49, 47 10 | orig: 49, 47 11 | offset: 0, 0 12 | index: -1 13 | BigBadGuy1 14 | rotate: false 15 | xy: 51, 0 16 | size: 49, 47 17 | orig: 49, 47 18 | offset: 0, 0 19 | index: -1 20 | RobotScan3 21 | rotate: false 22 | xy: 0, 49 23 | size: 30, 45 24 | orig: 30, 45 25 | offset: 0, 0 26 | index: -1 27 | RobotScan2 28 | rotate: false 29 | xy: 32, 49 30 | size: 30, 45 31 | orig: 30, 45 32 | offset: 0, 0 33 | index: -1 34 | RobotScan1 35 | rotate: false 36 | xy: 64, 49 37 | size: 30, 45 38 | orig: 30, 45 39 | offset: 0, 0 40 | index: -1 41 | RobotScan0 42 | rotate: false 43 | xy: 96, 49 44 | size: 30, 45 45 | orig: 30, 45 46 | offset: 0, 0 47 | index: -1 48 | RobotRight3 49 | rotate: false 50 | xy: 0, 96 51 | size: 30, 45 52 | orig: 30, 45 53 | offset: 0, 0 54 | index: -1 55 | RobotRight2 56 | rotate: false 57 | xy: 32, 96 58 | size: 30, 45 59 | orig: 30, 45 60 | offset: 0, 0 61 | index: -1 62 | RobotRight1 63 | rotate: false 64 | xy: 64, 96 65 | size: 30, 45 66 | orig: 30, 45 67 | offset: 0, 0 68 | index: -1 69 | RobotRight0 70 | rotate: false 71 | xy: 96, 96 72 | size: 30, 45 73 | orig: 30, 45 74 | offset: 0, 0 75 | index: -1 76 | RobotLeft3 77 | rotate: false 78 | xy: 0, 143 79 | size: 30, 45 80 | orig: 30, 45 81 | offset: 0, 0 82 | index: -1 83 | RobotLeft2 84 | rotate: false 85 | xy: 32, 143 86 | size: 30, 45 87 | orig: 30, 45 88 | offset: 0, 0 89 | index: -1 90 | RobotLeft1 91 | rotate: false 92 | xy: 64, 143 93 | size: 30, 45 94 | orig: 30, 45 95 | offset: 0, 0 96 | index: -1 97 | RobotLeft0 98 | rotate: false 99 | xy: 96, 143 100 | size: 30, 45 101 | orig: 30, 45 102 | offset: 0, 0 103 | index: -1 104 | pause 105 | rotate: false 106 | xy: 0, 190 107 | size: 44, 44 108 | orig: 44, 44 109 | offset: 0, 0 110 | index: -1 111 | HeroRight2 112 | rotate: false 113 | xy: 46, 190 114 | size: 29, 44 115 | orig: 29, 44 116 | offset: 0, 0 117 | index: -1 118 | HeroRight1 119 | rotate: false 120 | xy: 77, 190 121 | size: 29, 44 122 | orig: 29, 44 123 | offset: 0, 0 124 | index: -1 125 | HeroLeft2 126 | rotate: false 127 | xy: 0, 236 128 | size: 29, 44 129 | orig: 29, 44 130 | offset: 0, 0 131 | index: -1 132 | HeroLeft1 133 | rotate: false 134 | xy: 31, 236 135 | size: 29, 44 136 | orig: 29, 44 137 | offset: 0, 0 138 | index: -1 139 | 8x8 140 | rotate: false 141 | xy: 102, 0 142 | size: 12, 12 143 | orig: 12, 12 144 | offset: 0, 0 145 | index: -1 146 | RobotShot01 147 | rotate: false 148 | xy: 116, 0 149 | size: 9, 9 150 | orig: 9, 9 151 | offset: 0, 0 152 | index: -1 153 | PlayerShot01 154 | rotate: false 155 | xy: 102, 14 156 | size: 9, 9 157 | orig: 9, 9 158 | offset: 0, 0 159 | index: -1 160 | -------------------------------------------------------------------------------- /android/assets/data/textures/16/pack: -------------------------------------------------------------------------------- 1 | 2 | png1.png 3 | format: RGBA8888 4 | filter: Nearest,Nearest 5 | repeat: none 6 | BigBadGuy2 7 | rotate: false 8 | xy: 0, 0 9 | size: 33, 32 10 | orig: 33, 32 11 | offset: 0, 0 12 | index: -1 13 | BigBadGuy1 14 | rotate: false 15 | xy: 35, 0 16 | size: 33, 32 17 | orig: 33, 32 18 | offset: 0, 0 19 | index: -1 20 | pause 21 | rotate: false 22 | xy: 70, 0 23 | size: 30, 30 24 | orig: 30, 30 25 | offset: 0, 0 26 | index: -1 27 | HeroRight2 28 | rotate: false 29 | xy: 102, 0 30 | size: 20, 30 31 | orig: 20, 30 32 | offset: 0, 0 33 | index: -1 34 | HeroRight1 35 | rotate: false 36 | xy: 124, 0 37 | size: 20, 30 38 | orig: 20, 30 39 | offset: 0, 0 40 | index: -1 41 | HeroLeft2 42 | rotate: false 43 | xy: 146, 0 44 | size: 20, 30 45 | orig: 20, 30 46 | offset: 0, 0 47 | index: -1 48 | HeroLeft1 49 | rotate: false 50 | xy: 168, 0 51 | size: 20, 30 52 | orig: 20, 30 53 | offset: 0, 0 54 | index: -1 55 | RobotScan3 56 | rotate: false 57 | xy: 190, 0 58 | size: 18, 30 59 | orig: 18, 30 60 | offset: 0, 0 61 | index: -1 62 | RobotScan2 63 | rotate: false 64 | xy: 210, 0 65 | size: 18, 30 66 | orig: 18, 30 67 | offset: 0, 0 68 | index: -1 69 | RobotScan1 70 | rotate: false 71 | xy: 230, 0 72 | size: 18, 30 73 | orig: 18, 30 74 | offset: 0, 0 75 | index: -1 76 | RobotScan0 77 | rotate: false 78 | xy: 250, 0 79 | size: 18, 30 80 | orig: 18, 30 81 | offset: 0, 0 82 | index: -1 83 | RobotRight3 84 | rotate: false 85 | xy: 270, 0 86 | size: 18, 30 87 | orig: 18, 30 88 | offset: 0, 0 89 | index: -1 90 | RobotRight2 91 | rotate: false 92 | xy: 290, 0 93 | size: 18, 30 94 | orig: 18, 30 95 | offset: 0, 0 96 | index: -1 97 | RobotRight1 98 | rotate: false 99 | xy: 310, 0 100 | size: 18, 30 101 | orig: 18, 30 102 | offset: 0, 0 103 | index: -1 104 | RobotRight0 105 | rotate: false 106 | xy: 330, 0 107 | size: 18, 30 108 | orig: 18, 30 109 | offset: 0, 0 110 | index: -1 111 | RobotLeft3 112 | rotate: false 113 | xy: 350, 0 114 | size: 18, 30 115 | orig: 18, 30 116 | offset: 0, 0 117 | index: -1 118 | RobotLeft2 119 | rotate: false 120 | xy: 370, 0 121 | size: 18, 30 122 | orig: 18, 30 123 | offset: 0, 0 124 | index: -1 125 | RobotLeft1 126 | rotate: false 127 | xy: 390, 0 128 | size: 18, 30 129 | orig: 18, 30 130 | offset: 0, 0 131 | index: -1 132 | RobotLeft0 133 | rotate: false 134 | xy: 410, 0 135 | size: 18, 30 136 | orig: 18, 30 137 | offset: 0, 0 138 | index: -1 139 | 8x8 140 | rotate: false 141 | xy: 430, 0 142 | size: 8, 8 143 | orig: 8, 8 144 | offset: 0, 0 145 | index: -1 146 | RobotShot01 147 | rotate: false 148 | xy: 430, 10 149 | size: 6, 6 150 | orig: 6, 6 151 | offset: 0, 0 152 | index: -1 153 | PlayerShot01 154 | rotate: false 155 | xy: 430, 18 156 | size: 6, 6 157 | orig: 6, 6 158 | offset: 0, 0 159 | index: -1 160 | -------------------------------------------------------------------------------- /android/assets/data/textures/24/pack: -------------------------------------------------------------------------------- 1 | 2 | png1.png 3 | format: RGBA8888 4 | filter: Nearest,Nearest 5 | repeat: none 6 | BigBadGuy2 7 | rotate: false 8 | xy: 0, 0 9 | size: 49, 47 10 | orig: 49, 47 11 | offset: 0, 0 12 | index: -1 13 | BigBadGuy1 14 | rotate: false 15 | xy: 51, 0 16 | size: 49, 47 17 | orig: 49, 47 18 | offset: 0, 0 19 | index: -1 20 | RobotScan3 21 | rotate: false 22 | xy: 0, 49 23 | size: 30, 45 24 | orig: 30, 45 25 | offset: 0, 0 26 | index: -1 27 | RobotScan2 28 | rotate: false 29 | xy: 32, 49 30 | size: 30, 45 31 | orig: 30, 45 32 | offset: 0, 0 33 | index: -1 34 | RobotScan1 35 | rotate: false 36 | xy: 64, 49 37 | size: 30, 45 38 | orig: 30, 45 39 | offset: 0, 0 40 | index: -1 41 | RobotScan0 42 | rotate: false 43 | xy: 96, 49 44 | size: 30, 45 45 | orig: 30, 45 46 | offset: 0, 0 47 | index: -1 48 | RobotRight3 49 | rotate: false 50 | xy: 0, 96 51 | size: 30, 45 52 | orig: 30, 45 53 | offset: 0, 0 54 | index: -1 55 | RobotRight2 56 | rotate: false 57 | xy: 32, 96 58 | size: 30, 45 59 | orig: 30, 45 60 | offset: 0, 0 61 | index: -1 62 | RobotRight1 63 | rotate: false 64 | xy: 64, 96 65 | size: 30, 45 66 | orig: 30, 45 67 | offset: 0, 0 68 | index: -1 69 | RobotRight0 70 | rotate: false 71 | xy: 96, 96 72 | size: 30, 45 73 | orig: 30, 45 74 | offset: 0, 0 75 | index: -1 76 | RobotLeft3 77 | rotate: false 78 | xy: 0, 143 79 | size: 30, 45 80 | orig: 30, 45 81 | offset: 0, 0 82 | index: -1 83 | RobotLeft2 84 | rotate: false 85 | xy: 32, 143 86 | size: 30, 45 87 | orig: 30, 45 88 | offset: 0, 0 89 | index: -1 90 | RobotLeft1 91 | rotate: false 92 | xy: 64, 143 93 | size: 30, 45 94 | orig: 30, 45 95 | offset: 0, 0 96 | index: -1 97 | RobotLeft0 98 | rotate: false 99 | xy: 96, 143 100 | size: 30, 45 101 | orig: 30, 45 102 | offset: 0, 0 103 | index: -1 104 | pause 105 | rotate: false 106 | xy: 0, 190 107 | size: 44, 44 108 | orig: 44, 44 109 | offset: 0, 0 110 | index: -1 111 | HeroRight2 112 | rotate: false 113 | xy: 46, 190 114 | size: 29, 44 115 | orig: 29, 44 116 | offset: 0, 0 117 | index: -1 118 | HeroRight1 119 | rotate: false 120 | xy: 77, 190 121 | size: 29, 44 122 | orig: 29, 44 123 | offset: 0, 0 124 | index: -1 125 | HeroLeft2 126 | rotate: false 127 | xy: 0, 236 128 | size: 29, 44 129 | orig: 29, 44 130 | offset: 0, 0 131 | index: -1 132 | HeroLeft1 133 | rotate: false 134 | xy: 31, 236 135 | size: 29, 44 136 | orig: 29, 44 137 | offset: 0, 0 138 | index: -1 139 | 8x8 140 | rotate: false 141 | xy: 102, 0 142 | size: 12, 12 143 | orig: 12, 12 144 | offset: 0, 0 145 | index: -1 146 | RobotShot01 147 | rotate: false 148 | xy: 116, 0 149 | size: 9, 9 150 | orig: 9, 9 151 | offset: 0, 0 152 | index: -1 153 | PlayerShot01 154 | rotate: false 155 | xy: 102, 14 156 | size: 9, 9 157 | orig: 9, 9 158 | offset: 0, 0 159 | index: -1 160 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ParticleAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | import com.badlydrawngames.general.ParticleManager; 18 | import com.badlydrawngames.veryangryrobots.mobiles.BaseShot; 19 | import com.badlydrawngames.veryangryrobots.mobiles.Player; 20 | import com.badlydrawngames.veryangryrobots.mobiles.Robot; 21 | 22 | class ParticleAdapter implements WorldListener { 23 | 24 | final int PARTICLES = 32; 25 | 26 | final private World world; 27 | final private ParticleManager particleManager; 28 | private Color robotColor; 29 | private Color shotExplosionColor; 30 | 31 | public ParticleAdapter (World world, ParticleManager particleManager) { 32 | this.world = world; 33 | this.particleManager = particleManager; 34 | shotExplosionColor = new Color(1.0f, 0.5f, 0.0f, 1.0f); 35 | } 36 | 37 | public void setRobotColor (Color color) { 38 | this.robotColor = color; 39 | } 40 | 41 | public void update (float delta) { 42 | particleManager.update(delta); 43 | } 44 | 45 | @Override 46 | public void onEnteredRoom (float time, int robots) { 47 | particleManager.clear(); 48 | } 49 | 50 | @Override 51 | public void onPlayerHit () { 52 | Player player = world.getPlayer(); 53 | float x = player.x + player.width / 2; 54 | float y = player.y + player.height / 2; 55 | particleManager.add(x, y, 2 * PARTICLES, Color.WHITE); 56 | } 57 | 58 | @Override 59 | public void onRobotDestroyed (Robot robot) { 60 | float x = robot.x + robot.width / 2; 61 | float y = robot.y + robot.height / 2; 62 | particleManager.add(x, y, PARTICLES, robotColor); 63 | } 64 | 65 | @Override 66 | public void onShotDestroyed (BaseShot shot) { 67 | float x = shot.x + shot.width / 2; 68 | float y = shot.y + shot.height / 2; 69 | particleManager.add(x, y, PARTICLES / 8, shotExplosionColor); 70 | } 71 | 72 | @Override 73 | public void onCaptainActivated (float time) { 74 | } 75 | 76 | @Override 77 | public void onExitedRoom (float time, int robots) { 78 | } 79 | 80 | @Override 81 | public void onPlayerFired () { 82 | } 83 | 84 | @Override 85 | public void onPlayerSpawned () { 86 | } 87 | 88 | @Override 89 | public void onRobotFired (Robot robot) { 90 | } 91 | 92 | @Override 93 | public void onRobotHit (Robot robot) { 94 | } 95 | 96 | @Override 97 | public void onWorldReset () { 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/WorldNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | import com.badlydrawngames.veryangryrobots.mobiles.BaseShot; 18 | import com.badlydrawngames.veryangryrobots.mobiles.Robot; 19 | 20 | class WorldNotifier implements WorldListener { 21 | 22 | private final Array listeners; 23 | 24 | public WorldNotifier () { 25 | listeners = new Array(); 26 | } 27 | 28 | public void addListener (WorldListener listener) { 29 | listeners.add(listener); 30 | } 31 | 32 | @Override 33 | public void onCaptainActivated (float time) { 34 | for (WorldListener listener : listeners) { 35 | listener.onCaptainActivated(time); 36 | } 37 | } 38 | 39 | @Override 40 | public void onEnteredRoom (float time, int robots) { 41 | for (WorldListener listener : listeners) { 42 | listener.onEnteredRoom(time, robots); 43 | } 44 | } 45 | 46 | @Override 47 | public void onExitedRoom (float time, int robots) { 48 | for (WorldListener listener : listeners) { 49 | listener.onExitedRoom(time, robots); 50 | } 51 | } 52 | 53 | @Override 54 | public void onPlayerFired () { 55 | for (WorldListener listener : listeners) { 56 | listener.onPlayerFired(); 57 | } 58 | } 59 | 60 | @Override 61 | public void onPlayerHit () { 62 | for (WorldListener listener : listeners) { 63 | listener.onPlayerHit(); 64 | } 65 | } 66 | 67 | @Override 68 | public void onPlayerSpawned () { 69 | for (WorldListener listener : listeners) { 70 | listener.onPlayerSpawned(); 71 | } 72 | } 73 | 74 | @Override 75 | public void onRobotDestroyed (Robot robot) { 76 | for (WorldListener listener : listeners) { 77 | listener.onRobotDestroyed(robot); 78 | } 79 | } 80 | 81 | @Override 82 | public void onRobotFired (Robot robot) { 83 | for (WorldListener listener : listeners) { 84 | listener.onRobotFired(robot); 85 | } 86 | } 87 | 88 | @Override 89 | public void onRobotHit (Robot robot) { 90 | for (WorldListener listener : listeners) { 91 | listener.onRobotHit(robot); 92 | } 93 | } 94 | 95 | @Override 96 | public void onShotDestroyed (BaseShot shot) { 97 | for (WorldListener listener : listeners) { 98 | listener.onShotDestroyed(shot); 99 | } 100 | } 101 | 102 | @Override 103 | public void onWorldReset () { 104 | for (WorldListener listener : listeners) { 105 | listener.onWorldReset(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | android { 2 | buildToolsVersion "19.0.3" 3 | compileSdkVersion 17 4 | sourceSets { 5 | main { 6 | manifest.srcFile 'AndroidManifest.xml' 7 | java.srcDirs = ['src'] 8 | resources.srcDirs = ['src'] 9 | aidl.srcDirs = ['src'] 10 | renderscript.srcDirs = ['src'] 11 | res.srcDirs = ['res'] 12 | assets.srcDirs = ['assets'] 13 | } 14 | 15 | instrumentTest.setRoot('tests') 16 | } 17 | } 18 | 19 | // needed to add JNI shared libraries to APK when compiling on CLI 20 | tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> 21 | pkgTask.jniFolders = new HashSet() 22 | pkgTask.jniFolders.add(new File(projectDir, 'libs')) 23 | } 24 | 25 | // called every time gradle gets executed, takes the native dependencies of 26 | // the natives configuration, and extracts them to the proper libs/ folders 27 | // so they get packed with the APK. 28 | task copyAndroidNatives() { 29 | file("libs/armeabi/").mkdirs(); 30 | file("libs/armeabi-v7a/").mkdirs(); 31 | file("libs/x86/").mkdirs(); 32 | 33 | configurations.natives.files.each { jar -> 34 | def outputDir = null 35 | if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") 36 | if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") 37 | if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 38 | if(outputDir != null) { 39 | copy { 40 | from zipTree(jar) 41 | into outputDir 42 | include "*.so" 43 | } 44 | } 45 | } 46 | } 47 | 48 | task run(type: Exec) { 49 | def adb = "$System.env.ANDROID_HOME/platform-tools/adb" 50 | commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.badlydrawngames.veryangryrobots.android/com.badlydrawngames.veryangryrobots.android.VeryAngryRobotsActivity' 51 | } 52 | 53 | // sets up the Android Eclipse project, using the old Ant based build. 54 | eclipse { 55 | // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin 56 | // ignores any nodes added in classpath.file.withXml 57 | sourceSets { 58 | main { 59 | java.srcDirs "src", 'gen' 60 | } 61 | } 62 | 63 | jdt { 64 | sourceCompatibility = 1.6 65 | targetCompatibility = 1.6 66 | } 67 | 68 | classpath { 69 | plusConfigurations += [ project.configurations.compile ] 70 | containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES' 71 | } 72 | 73 | project { 74 | name = appName + "-android" 75 | natures 'com.android.ide.eclipse.adt.AndroidNature' 76 | buildCommands.clear(); 77 | buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder" 78 | buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder" 79 | buildCommand "org.eclipse.jdt.core.javabuilder" 80 | buildCommand "com.android.ide.eclipse.adt.ApkBuilder" 81 | } 82 | } 83 | 84 | // sets up the Android Idea project, using the old Ant based build. 85 | idea { 86 | module { 87 | sourceDirs += file("src"); 88 | scopes = [ COMPILE: [plus:[project.configurations.compile]]] 89 | 90 | iml { 91 | withXml { 92 | def node = it.asNode() 93 | def builder = NodeBuilder.newInstance(); 94 | builder.current = node; 95 | builder.component(name: "FacetManager") { 96 | facet(type: "android", name: "Android") { 97 | configuration { 98 | option(name: "UPDATE_PROPERTY_FILES", value:"true") 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/SimpleButton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | import com.badlogic.gdx.graphics.g2d.BitmapFont; 18 | import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; 19 | import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds; 20 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 21 | import com.badlydrawngames.veryangryrobots.Assets; 22 | 23 | public class SimpleButton { 24 | private HAlignment alignment; 25 | private String text; 26 | private boolean wasPressed; 27 | private float x; 28 | private float y; 29 | private float w; 30 | private float h; 31 | private boolean activated; 32 | private boolean down; 33 | private BitmapFont font; 34 | private float textHeight; 35 | 36 | public SimpleButton (String text, BitmapFont font) { 37 | this.text = text; 38 | this.wasPressed = false; 39 | this.activated = false; 40 | this.down = false; 41 | this.font = font; 42 | TextBounds bounds = Assets.textFont.getBounds(text); 43 | textHeight = bounds.height; 44 | w = bounds.width * 2; 45 | h = bounds.height * 2; 46 | alignment = HAlignment.CENTER; 47 | } 48 | 49 | public void setWidth (float width) { 50 | w = width; 51 | } 52 | 53 | public void setHeight (float height) { 54 | h = height; 55 | } 56 | 57 | public void setAlignment (HAlignment alignment) { 58 | this.alignment = alignment; 59 | } 60 | 61 | public void update (float delta, boolean justTouched, boolean isTouched, boolean justReleased, float x, float y) { 62 | wasPressed = false; 63 | if (justTouched && inBounds(x, y)) { 64 | activated = true; 65 | down = true; 66 | } else if (isTouched) { 67 | down = activated && inBounds(x, y); 68 | } else if (justReleased) { 69 | wasPressed = activated && inBounds(x, y); 70 | activated = false; 71 | down = false; 72 | } else { 73 | activated = false; 74 | } 75 | } 76 | 77 | private boolean inBounds (float x, float y) { 78 | return x >= this.x && x < this.x + this.w && y >= this.y && y < this.y + this.h; 79 | } 80 | 81 | public void draw (SpriteBatch spriteBatch) { 82 | Color oldColor = font.getColor(); 83 | if (down) { 84 | spriteBatch.setColor(Color.RED); 85 | } else { 86 | spriteBatch.setColor(Color.BLUE); 87 | } 88 | spriteBatch.draw(Assets.pureWhiteTextureRegion, x, y, w, h); 89 | spriteBatch.setColor(Color.WHITE); 90 | if (down) { 91 | font.setColor(oldColor.r / 2, oldColor.g / 2, oldColor.b / 2, oldColor.a); 92 | } 93 | float textX = x; 94 | float textY = y + h; 95 | textY -= (h - textHeight) / 2; 96 | font.drawWrapped(spriteBatch, text, textX, textY, w, alignment); 97 | font.setColor(oldColor); 98 | } 99 | 100 | public boolean wasPressed () { 101 | return this.wasPressed; 102 | } 103 | 104 | public void rightOn (float right) { 105 | x = right - w; 106 | } 107 | 108 | public void leftOn (float left) { 109 | x = left; 110 | } 111 | 112 | public void centerHorizontallyOn (float centerX) { 113 | x = centerX - w / 2; 114 | } 115 | 116 | public void bottomOn (float bottom) { 117 | y = bottom; 118 | } 119 | 120 | public void topOn (float top) { 121 | y = top - h; 122 | } 123 | 124 | public void centerVerticallyOn (float centerY) { 125 | y = centerY - h / 2; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/SoundManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.audio.Sound; 17 | import com.badlydrawngames.veryangryrobots.StatusManager.Achievements; 18 | import com.badlydrawngames.veryangryrobots.mobiles.BaseShot; 19 | import com.badlydrawngames.veryangryrobots.mobiles.Robot; 20 | 21 | import static com.badlogic.gdx.math.MathUtils.*; 22 | 23 | public class SoundManager implements WorldListener, AchievementsListener, ScoreListener { 24 | private static final float MIN_TAUNT_INTERVAL = 2.5f; 25 | private static final float MAX_TAUNT_INTERVAL = 15.0f; 26 | 27 | private float now; 28 | private float nextTauntTime; 29 | private float lastRobotFireTime; 30 | private float lastRobotHitTime; 31 | private float lastPlayerHitTime; 32 | private boolean canTaunt; 33 | private boolean isChicken; 34 | private int lives; 35 | 36 | @Override 37 | public void onEnteredRoom (float time, int robots) { 38 | Assets.playSound(Assets.spawnPlayerSound); 39 | } 40 | 41 | @Override 42 | public void onExitedRoom (float time, int robots) { 43 | isChicken = robots > 0; 44 | if (isChicken) { 45 | Assets.playSound(Assets.exitRoomAsChickenSpeech); 46 | } 47 | canTaunt = false; 48 | } 49 | 50 | @Override 51 | public void onPlayerSpawned () { 52 | canTaunt = true; 53 | scheduleTaunt(); 54 | } 55 | 56 | @Override 57 | public void onPlayerFired () { 58 | Assets.playSound(Assets.playerShotSound); 59 | } 60 | 61 | @Override 62 | public void onRobotFired (Robot robot) { 63 | if (lastRobotFireTime != now) { 64 | Assets.playSound(Assets.robotShotSound); 65 | lastRobotFireTime = now; 66 | } 67 | } 68 | 69 | @Override 70 | public void onPlayerHit () { 71 | if (lastPlayerHitTime != now) { 72 | canTaunt = false; 73 | Assets.playSound(Assets.killPlayerSound); 74 | lastPlayerHitTime = now; 75 | } 76 | } 77 | 78 | @Override 79 | public void onRobotDestroyed (Robot robot) { 80 | if (lastRobotHitTime != now) { 81 | Assets.playSound(Assets.killRobotSound); 82 | lastRobotHitTime = now; 83 | } 84 | } 85 | 86 | @Override 87 | public void onCaptainActivated (float time) { 88 | Assets.playSound(Assets.captainEnterRoomSpeech); 89 | // We can't do much about any speech going on, but we can make sure nothing else talks over the top of this 90 | // one. 91 | scheduleTaunt(); 92 | } 93 | 94 | @Override 95 | public void onRobotHit (Robot robot) { 96 | } 97 | 98 | @Override 99 | public void onShotDestroyed (BaseShot shot) { 100 | } 101 | 102 | @Override 103 | public void onWorldReset () { 104 | isChicken = false; 105 | lives = 0; 106 | } 107 | 108 | @Override 109 | public void onAttained (Achievements achievement) { 110 | Assets.playSound(Assets.achievementSound); 111 | } 112 | 113 | public void update (float delta) { 114 | now += delta; 115 | if (canTaunt && now >= nextTauntTime) { 116 | Sound[] sounds = isChicken ? Assets.chickenTaunts : Assets.standardTaunts; 117 | Assets.playSound(sounds[random(sounds.length - 1)]); 118 | scheduleTaunt(); 119 | } 120 | } 121 | 122 | private void scheduleTaunt () { 123 | nextTauntTime = now + random(MIN_TAUNT_INTERVAL, MAX_TAUNT_INTERVAL); 124 | } 125 | 126 | @Override 127 | public void onScoreChanged (int score) { 128 | } 129 | 130 | @Override 131 | public void onLivesChanged (int lives) { 132 | if (lives - 1 == this.lives) { 133 | Assets.playSound(Assets.extraLifeSound); 134 | } 135 | this.lives = lives; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /android/assets/data/veryangryrobots.properties: -------------------------------------------------------------------------------- 1 | # Game window dimensions in virtual coordinates. 2 | Global.screenWidth = 480 3 | Global.screenHeight = 320 4 | Global.statusAreaHeight = 24 5 | 6 | # Fonts. 7 | Global.scoreFont = wellbutrin.fnt 8 | Global.flyupFont = ocr_a_small.fnt 9 | Global.textFont = ocr_a.fnt 10 | 11 | # Robot numbers. 12 | Global.initialRobots = 6 13 | Global.maxRobots = 12 14 | 15 | # Timings. 16 | Global.deadTime = 2.0 17 | Global.amnestyTime = 2.0 18 | Global.roomTransitionTime = 0.333 19 | 20 | # Level progression. 21 | Level.robotIncrement = 3 22 | Level.0.robotShots = 0 23 | Level.0.score = 0 24 | Level.1.robotShots = 1 25 | Level.1.score = 300 26 | Level.2.robotShots = 2 27 | Level.2.score = 1000 28 | Level.3.robotShots = 3 29 | Level.3.score = 2000 30 | Level.4.robotShots = 4 31 | Level.4.score = 4000 32 | Level.5.robotShots = 5 33 | Level.5.score = 5000 34 | Level.6.robotShots = 1 35 | Level.6.score = 6000 36 | Level.7.robotShots = 2 37 | Level.7.score = 8000 38 | Level.8.robotShots = 3 39 | Level.8.score = 10000 40 | Level.9.robotShots = 4 41 | Level.9.score = 12500 42 | Level.10.robotShots = 5 43 | Level.10.score = 15000 44 | Level.11.robotShots = 6 45 | Level.11.score = 20000 46 | 47 | # Player attributes. 48 | Player.borderWidthPercent = 25.0 49 | Player.borderHeightPercent = 6.7 50 | Player.frameDuration = 0.2 51 | Player.speed = 12.5 52 | Player.maxShots = 4 53 | Player.lives = 3 54 | Player.firingInterval = 0.25 55 | Player.firstExtraLife = 10000 56 | Player.secondExtraLife = 50000 57 | 58 | # Captain attributes. 59 | Captain.borderWidthPercent = 16.7 60 | Captain.borderHeightPercent = 16.7 61 | Captain.frameDuration = 0.5 62 | Captain.speed = 3.75 63 | Captain.bounceSize = 5.625 64 | Captain.bounceFrequency = 10.0 65 | Captain.minLurkTime = 2.0 66 | Captain.lurkMultiplier = 2.0 67 | 68 | # Robot attributes. 69 | Robot.frameDuration = 0.1 70 | Robot.speed = 1.25 71 | Robot.maxShots = 6 72 | Robot.score = 50 73 | # Game window dimensions in virtual coordinates. 74 | Global.screenWidth = 480 75 | Global.screenHeight = 320 76 | Global.statusAreaHeight = 24 77 | 78 | # Fonts. 79 | Global.scoreFont = wellbutrin.fnt 80 | Global.flyupFont = ocr_a_small.fnt 81 | Global.textFont = ocr_a.fnt 82 | 83 | # Robot numbers. 84 | Global.initialRobots = 6 85 | Global.maxRobots = 12 86 | 87 | # Timings. 88 | Global.deadTime = 2.0 89 | Global.amnestyTime = 2.0 90 | Global.roomTransitionTime = 0.333 91 | 92 | # Level progression. 93 | Level.robotIncrement = 3 94 | Level.0.robotShots = 0 95 | Level.0.score = 0 96 | Level.1.robotShots = 1 97 | Level.1.score = 300 98 | Level.2.robotShots = 2 99 | Level.2.score = 1000 100 | Level.3.robotShots = 3 101 | Level.3.score = 2000 102 | Level.4.robotShots = 4 103 | Level.4.score = 4000 104 | Level.5.robotShots = 5 105 | Level.5.score = 5000 106 | Level.6.robotShots = 1 107 | Level.6.score = 6000 108 | Level.7.robotShots = 2 109 | Level.7.score = 8000 110 | Level.8.robotShots = 3 111 | Level.8.score = 10000 112 | Level.9.robotShots = 4 113 | Level.9.score = 12500 114 | Level.10.robotShots = 5 115 | Level.10.score = 15000 116 | Level.11.robotShots = 6 117 | Level.11.score = 20000 118 | 119 | # Player attributes. 120 | Player.borderWidthPercent = 25.0 121 | Player.borderHeightPercent = 6.7 122 | Player.frameDuration = 0.2 123 | Player.speed = 12.5 124 | Player.maxShots = 4 125 | Player.lives = 3 126 | Player.firingInterval = 0.25 127 | Player.firstExtraLife = 10000 128 | Player.secondExtraLife = 50000 129 | 130 | # Captain attributes. 131 | Captain.borderWidthPercent = 16.7 132 | Captain.borderHeightPercent = 16.7 133 | Captain.frameDuration = 0.5 134 | Captain.speed = 3.75 135 | Captain.bounceSize = 5.625 136 | Captain.bounceFrequency = 10.0 137 | Captain.minLurkTime = 2.0 138 | Captain.lurkMultiplier = 2.0 139 | 140 | # Robot attributes. 141 | Robot.frameDuration = 0.1 142 | Robot.speed = 1.25 143 | Robot.maxShots = 6 144 | Robot.score = 50 145 | Robot.bonusScore = 100 146 | 147 | # PlayerShot attributes. 148 | PlayerShot.speed = 31.25 149 | 150 | # RobotShot attributes. 151 | RobotShot.slowSpeed = 4.6875 152 | RobotShot.fastSpeed = 6.0 153 | 154 | # Maze attributes. 155 | Maze.hCells = 5 156 | Maze.vCells = 3 157 | 158 | # Achievements. 159 | achievements.cleanRoomsForPerfectionist = 10 160 | achievements.robotsForRobocide = 50 161 | achievements.roomsForLuckyJim = 10 162 | achievements.roomsForChicken = 5 163 | achievements.gamesForAddict = 10 164 | achievements.daredevilSeconds = 10 165 | 166 | # Status display. 167 | status.achievementDisplayTime = 5.0 168 | status.achievementFlashCycleLength = 0.5 169 | status.achievementFlashOnPercent = 50 170 | 171 | # Flyups. 172 | flyup.lifetime = 1.0 173 | flyup.speed = 1.5625 174 | 175 | # Particles. 176 | particle.size = 0.1875 177 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoresScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import static com.badlydrawngames.veryangryrobots.Assets.VIRTUAL_HEIGHT; 17 | import static com.badlydrawngames.veryangryrobots.Assets.VIRTUAL_WIDTH; 18 | 19 | import com.badlogic.gdx.Gdx; 20 | import com.badlogic.gdx.Preferences; 21 | import com.badlogic.gdx.graphics.Color; 22 | import com.badlogic.gdx.graphics.GL20; 23 | import com.badlogic.gdx.graphics.OrthographicCamera; 24 | import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; 25 | import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds; 26 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 27 | import com.badlydrawngames.general.CameraHelper; 28 | import com.badlydrawngames.general.CameraHelper.ViewportMode; 29 | import com.badlydrawngames.general.GameScreen; 30 | import com.badlydrawngames.general.ScoreString; 31 | 32 | public class ScoresScreen extends GameScreen { 33 | 34 | private static final String LAST_SCORE = "Score:"; 35 | private static final String TOP_SCORE = "Best: "; 36 | private static final String VERY_ANGRY_ROBOTS = "VeryAngryRobots"; 37 | private static final String TOP_SCORE_PREF = "top score"; 38 | private static final String TAP_TO_CONTINUE = "Tap to continue"; 39 | 40 | private ScoreString scoreString; 41 | private ScoreString topScoreString; 42 | private OrthographicCamera scoreCam; 43 | private SpriteBatch spriteBatch; 44 | private boolean touched; 45 | private int topScore; 46 | private final Preferences preferences; 47 | private float stateTime; 48 | 49 | public ScoresScreen (VeryAngryRobotsGame game) { 50 | super(game); 51 | scoreCam = CameraHelper.createCamera2(ViewportMode.PIXEL_PERFECT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, Assets.pixelDensity); 52 | spriteBatch = new SpriteBatch(); 53 | spriteBatch.setProjectionMatrix(scoreCam.combined); 54 | scoreString = new ScoreString(); 55 | topScoreString = new ScoreString(); 56 | preferences = Gdx.app.getPreferences(VERY_ANGRY_ROBOTS); 57 | topScore = preferences.getInteger(TOP_SCORE_PREF, 1000); 58 | topScoreString.setScore(topScore); 59 | stateTime = 0.0f; 60 | } 61 | 62 | public void setScore (int score) { 63 | scoreString.setScore(score); 64 | if (score > topScore) { 65 | topScore = score; 66 | preferences.putInteger(TOP_SCORE_PREF, topScore); 67 | preferences.flush(); 68 | topScoreString.setScore(score); 69 | } 70 | } 71 | 72 | @Override 73 | public void render (float delta) { 74 | stateTime += delta; 75 | if (Gdx.input.justTouched()) { 76 | touched = true; 77 | } else if (touched && !Gdx.input.isTouched()) { 78 | touched = false; 79 | game.setScreen(game.mainMenuScreen); 80 | } else { 81 | Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 82 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 83 | spriteBatch.begin(); 84 | Assets.scoreFont.setColor(Color.WHITE); 85 | TextBounds b = Assets.scoreFont.getBounds(LAST_SCORE); 86 | float w = b.width + Assets.scoreFont.getSpaceWidth(); 87 | b = Assets.scoreFont.getBounds(scoreString); 88 | float w2 = b.width; 89 | float x = (VIRTUAL_WIDTH - (w + w2)) / 2.0f; 90 | float y = 3 * VIRTUAL_HEIGHT / 4.0f; 91 | Assets.scoreFont.setColor(Color.WHITE); 92 | Assets.scoreFont.draw(spriteBatch, TOP_SCORE, x, y); 93 | Assets.scoreFont.draw(spriteBatch, topScoreString, x + w, y); 94 | 95 | b = Assets.scoreFont.getBounds(TOP_SCORE); 96 | w = b.width + Assets.scoreFont.getSpaceWidth(); 97 | b = Assets.scoreFont.getBounds(topScoreString); 98 | w2 = b.width; 99 | x = (VIRTUAL_WIDTH - (w + w2)) / 2.0f; 100 | y += 2 * b.height; 101 | Assets.scoreFont.draw(spriteBatch, LAST_SCORE, x, y); 102 | Assets.scoreFont.draw(spriteBatch, scoreString, x + w, y); 103 | 104 | if (stateTime % 1.0f < 0.5f) { 105 | Assets.textFont.setColor(Color.WHITE); 106 | Assets.textFont.drawWrapped(spriteBatch, TAP_TO_CONTINUE, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, HAlignment.CENTER); 107 | } 108 | spriteBatch.end(); 109 | } 110 | } 111 | 112 | @Override 113 | public void show () { 114 | Gdx.input.setCatchBackKey(true); 115 | stateTime = 0.0f; 116 | } 117 | 118 | @Override 119 | public void hide () { 120 | Gdx.input.setCatchBackKey(false); 121 | } 122 | 123 | @Override 124 | public void resume () { 125 | Gdx.input.setCatchBackKey(true); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/StatusView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.graphics.OrthographicCamera; 17 | import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; 18 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 19 | import com.badlydrawngames.general.CameraHelper; 20 | import com.badlydrawngames.general.CameraHelper.ViewportMode; 21 | import com.badlydrawngames.general.Config; 22 | import com.badlydrawngames.general.ScoreString; 23 | import com.badlydrawngames.veryangryrobots.StatusManager.Achievements; 24 | 25 | import static com.badlydrawngames.veryangryrobots.Assets.*; 26 | 27 | public class StatusView implements ScoreListener, AchievementsListener { 28 | 29 | private static final float ACHIEVEMENT_DISPLAY_TIME = Config.asFloat("status.achievementDisplayTime", 10.0f); 30 | private static final float ACHIEVEMENT_FLASH_CYCLE = Config.asFloat("status.achievementFlashCycleLength", 1.0f); 31 | private static final float ACHIEVEMENT_FLASH_ON_PERCENT = Config.asFloat("status.achievementFlashOnPercent", 50.0f); 32 | private static final float ACHIEVEMENT_FLASH_ON_TIME = ACHIEVEMENT_FLASH_CYCLE * ACHIEVEMENT_FLASH_ON_PERCENT / 100.0f; 33 | 34 | private static final String RESUME_TEXT = "Tap to resume or press <> to quit"; 35 | 36 | private final World world; 37 | private final OrthographicCamera statusCam; 38 | private final SpriteBatch spriteBatch; 39 | private ScoreString scoreString; 40 | private int lives; 41 | private Achievements achievement; 42 | private float achievementTime; 43 | private float now; 44 | 45 | public StatusView (World world) { 46 | this.world = world; 47 | scoreString = new ScoreString(); 48 | statusCam = CameraHelper.createCamera2(ViewportMode.PIXEL_PERFECT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, Assets.pixelDensity); 49 | spriteBatch = new SpriteBatch(); 50 | spriteBatch.setProjectionMatrix(statusCam.combined); 51 | } 52 | 53 | public void render (float delta) { 54 | now += delta; 55 | spriteBatch.begin(); 56 | if (!world.isPaused()) { 57 | drawPauseButton(); 58 | drawScore(); 59 | drawAchievements(); 60 | drawLives(); 61 | } else { 62 | drawPaused(); 63 | } 64 | spriteBatch.end(); 65 | } 66 | 67 | private void drawPauseButton () { 68 | float w = Assets.pauseButton.getRegionWidth() / Assets.pixelDensity; 69 | float h = Assets.pauseButton.getRegionHeight() / Assets.pixelDensity; 70 | float y = VIRTUAL_HEIGHT - h; 71 | float x = 0.0f; 72 | spriteBatch.draw(Assets.pauseButton, x, y, w, h); 73 | } 74 | 75 | private void drawScore () { 76 | Assets.scoreFont.setColor(1.0f, 1.0f, 1.0f, 1.0f); 77 | Assets.scoreFont.draw(spriteBatch, scoreString, 2, VIRTUAL_HEIGHT); 78 | ; 79 | } 80 | 81 | private void drawAchievements () { 82 | if (achievement != null) { 83 | float elapsed = now - achievementTime; 84 | if (elapsed < ACHIEVEMENT_DISPLAY_TIME) { 85 | if (elapsed % ACHIEVEMENT_FLASH_CYCLE < ACHIEVEMENT_FLASH_ON_TIME) { 86 | String summary = achievement.summary(); 87 | float x = VIRTUAL_WIDTH * 0.5f; 88 | float w = VIRTUAL_WIDTH - x - (Assets.playerWalkingRight1.getRegionHeight() / Assets.pixelDensity) * 4; 89 | float y = VIRTUAL_HEIGHT - 1 + Assets.textFont.getCapHeight() / 2; 90 | Assets.textFont.drawWrapped(spriteBatch, summary, x, y, w, HAlignment.LEFT); 91 | } 92 | } else { 93 | achievement = null; 94 | } 95 | } 96 | } 97 | 98 | private void drawLives () { 99 | float h = Assets.playerWalkingRight1.getRegionHeight() / Assets.pixelDensity; 100 | float y = VIRTUAL_HEIGHT - h; 101 | float w = Assets.playerWalkingRight1.getRegionWidth() / Assets.pixelDensity; 102 | float x = VIRTUAL_WIDTH - w; 103 | for (int i = 0; i < lives - 1; i++) { 104 | spriteBatch.draw(Assets.playerWalkingRight1, x, y, w, h); 105 | x -= w; 106 | } 107 | } 108 | 109 | private void drawPaused () { 110 | if (world.getPausedTime() % 1.0f < 0.5f) { 111 | float y = VIRTUAL_HEIGHT - 1 + Assets.scoreFont.getCapHeight() / 2; 112 | Assets.textFont.setColor(1.0f, 1.0f, 1.0f, 1.0f); 113 | Assets.textFont.drawWrapped(spriteBatch, RESUME_TEXT, 0.0f, y, VIRTUAL_WIDTH, HAlignment.CENTER); 114 | } 115 | } 116 | 117 | @Override 118 | public void onScoreChanged (int score) { 119 | scoreString.setScore(score); 120 | } 121 | 122 | @Override 123 | public void onLivesChanged (int lives) { 124 | this.lives = lives; 125 | } 126 | 127 | @Override 128 | public void onAttained (Achievements achievement) { 129 | this.achievement = achievement; 130 | this.achievementTime = now; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/MazeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.utils.IntArray; 17 | 18 | import static com.badlogic.gdx.math.MathUtils.*; 19 | 20 | /** This class makes a maze using the recursive division method described on Wikipedia. */ 22 | public final class MazeGenerator { 23 | 24 | private int width; 25 | private int height; 26 | private int doorPos; 27 | 28 | private IntArray walls; 29 | private IntArray doors; 30 | 31 | public MazeGenerator (int width, int height) { 32 | // Pre: width is odd 33 | // Pre: height is odd 34 | // Pre: width > 2 35 | // Pre: height > 2 36 | this.width = width; 37 | this.height = height; 38 | walls = new IntArray(); 39 | doors = new IntArray(); 40 | } 41 | 42 | public MazeGenerator rebuild (int doorPos) { 43 | createMaze(doorPos); 44 | this.doorPos = doorPos; 45 | return this; 46 | } 47 | 48 | public int getWidth () { 49 | return width; 50 | } 51 | 52 | public int getHeight () { 53 | return height; 54 | } 55 | 56 | public int getDoorPos () { 57 | return doorPos; 58 | } 59 | 60 | public IntArray getWalls () { 61 | return walls; 62 | } 63 | 64 | public IntArray getDoors () { 65 | return doors; 66 | } 67 | 68 | private void createMaze (int doorPos) { 69 | walls.clear(); 70 | doors.clear(); 71 | addOuterWalls(); 72 | addDoors(doorPos); 73 | subdivideChamber(0, 0, width, height); 74 | } 75 | 76 | private void addOuterWalls () { 77 | addHWall(0, width / 2, 0); 78 | addHWall(width / 2 + 1, width, 0); 79 | addHWall(0, width / 2, height); 80 | addHWall(width / 2 + 1, width, height); 81 | addVWall(0, 0, height / 2); 82 | addVWall(0, height / 2 + 1, height); 83 | addVWall(width, 0, height / 2); 84 | addVWall(width, height / 2 + 1, height); 85 | } 86 | 87 | private void subdivideChamber (int x1, int y1, int x2, int y2) { 88 | // Get the size of the chamber and bail if it is too small to divide. 89 | int w = x2 - x1; 90 | int h = y2 - y1; 91 | if (w < 2 || h < 2) return; 92 | 93 | // Pick a point in the middle of the chamber. 94 | int cx = random(x1 + 1, x2 - 1); 95 | int cy = random(y1 + 1, y2 - 1); 96 | 97 | // Choose the solid wall. 98 | int solid = random(0, 3); 99 | 100 | // Add the internal walls. 101 | addHWall(x1, cx, cy, solid == 0); 102 | addHWall(cx, x2, cy, solid == 1); 103 | addVWall(cx, y1, cy, solid == 2); 104 | addVWall(cx, cy, y2, solid == 3); 105 | 106 | // Create the subchambers. 107 | subdivideChamber(x1, y1, cx, cy); 108 | subdivideChamber(cx, y1, x2, cy); 109 | subdivideChamber(x1, cy, cx, y2); 110 | subdivideChamber(cx, cy, x2, y2); 111 | } 112 | 113 | private void addHWall (int x1, int x2, int y, boolean solid) { 114 | int length = x2 - x1; 115 | if (length < 2) return; 116 | if (!solid) { 117 | int x = random(x1, x2 - 1); 118 | addHWall(x1, x, y); 119 | addHWall(x + 1, x2, y); 120 | } else { 121 | addHWall(x1, x2, y); 122 | } 123 | } 124 | 125 | private void addHWall (int x1, int x2, int y) { 126 | if (x2 <= x1) return; 127 | addWall(x1, y, x2, y); 128 | } 129 | 130 | private void addVWall (int x, int y1, int y2, boolean solid) { 131 | int length = y2 - y1; 132 | if (length < 2) return; 133 | if (!solid) { 134 | int y = random(y1, y2 - 1); 135 | addVWall(x, y1, y); 136 | addVWall(x, y + 1, y2); 137 | } else { 138 | addVWall(x, y1, y2); 139 | } 140 | } 141 | 142 | private void addVWall (int x, int y1, int y2) { 143 | if (y2 <= y1) return; 144 | addWall(x, y1, x, y2); 145 | } 146 | 147 | private void addWall (int x1, int y1, int x2, int y2) { 148 | walls.add(x1); 149 | walls.add(y1); 150 | walls.add(x2); 151 | walls.add(y2); 152 | } 153 | 154 | private void addDoors (int doorPos) { 155 | if ((doorPos & DoorPositions.MIN_Y) == DoorPositions.MIN_Y) { 156 | addHDoor(width / 2, 0); 157 | } 158 | if ((doorPos & DoorPositions.MAX_Y) == DoorPositions.MAX_Y) { 159 | addHDoor(width / 2, height); 160 | } 161 | if ((doorPos & DoorPositions.MIN_X) == DoorPositions.MIN_X) { 162 | addVDoor(0, height / 2); 163 | } 164 | if ((doorPos & DoorPositions.MAX_X) == DoorPositions.MAX_X) { 165 | addVDoor(width, height / 2); 166 | } 167 | } 168 | 169 | private void addHDoor (int x, int y) { 170 | addDoor(x, y, x + 1, y); 171 | } 172 | 173 | private void addVDoor (int x, int y) { 174 | addDoor(x, y, x, y + 1); 175 | } 176 | 177 | private void addDoor (int x1, int y1, int x2, int y2) { 178 | doors.add(x1); 179 | doors.add(y1); 180 | doors.add(x2); 181 | doors.add(y2); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/MainMenuScreen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import static com.badlydrawngames.veryangryrobots.Assets.VIRTUAL_HEIGHT; 17 | import static com.badlydrawngames.veryangryrobots.Assets.VIRTUAL_WIDTH; 18 | 19 | import com.badlogic.gdx.Gdx; 20 | import com.badlogic.gdx.audio.Sound; 21 | import com.badlogic.gdx.graphics.Color; 22 | import com.badlogic.gdx.graphics.GL20; 23 | import com.badlogic.gdx.graphics.OrthographicCamera; 24 | import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; 25 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 26 | import com.badlogic.gdx.math.Vector3; 27 | import com.badlydrawngames.general.CameraHelper; 28 | import com.badlydrawngames.general.CameraHelper.ViewportMode; 29 | import com.badlydrawngames.general.GameScreen; 30 | import com.badlydrawngames.general.SimpleButton; 31 | 32 | public class MainMenuScreen extends GameScreen { 33 | 34 | final String TITLE = "VERY ANGRY ROBOTS"; 35 | final String JIBBER_JABBER = "Robots are deadly\nWalls are deadly\nDoors are deadly\nShots are deadly\n\nDestroy robots to get the high score"; 36 | SpriteBatch spriteBatch; 37 | private OrthographicCamera menuCam; 38 | private SimpleButton playButton; 39 | private SimpleButton scoresButton; 40 | private Vector3 touchPoint; 41 | private boolean wasTouched; 42 | 43 | public MainMenuScreen (VeryAngryRobotsGame game) { 44 | super(game); 45 | menuCam = CameraHelper.createCamera2(ViewportMode.PIXEL_PERFECT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, Assets.pixelDensity); 46 | spriteBatch = new SpriteBatch(); 47 | spriteBatch.setProjectionMatrix(menuCam.combined); 48 | touchPoint = new Vector3(); 49 | createButtons(); 50 | } 51 | 52 | private void createButtons () { 53 | playButton = createPlayButton(); 54 | playButton.setWidth(VIRTUAL_WIDTH / 4); 55 | playButton.setHeight(VIRTUAL_HEIGHT / 4); 56 | if (game.canShowScores()) { 57 | scoresButton = createShowScoresButton(); 58 | scoresButton.setWidth(VIRTUAL_WIDTH / 4); 59 | scoresButton.setHeight(VIRTUAL_HEIGHT / 4); 60 | scoresButton.rightOn(VIRTUAL_WIDTH); 61 | scoresButton.bottomOn(1.0f); 62 | playButton.leftOn(0); 63 | playButton.bottomOn(1.0f); 64 | } else { 65 | playButton.bottomOn(1.0f); 66 | playButton.centerHorizontallyOn(VIRTUAL_WIDTH / 2); 67 | } 68 | } 69 | 70 | private SimpleButton createPlayButton () { 71 | return new SimpleButton("Play", Assets.textFont); 72 | } 73 | 74 | private SimpleButton createShowScoresButton () { 75 | return new SimpleButton("Scores", Assets.textFont); 76 | } 77 | 78 | @Override 79 | public void render (float delta) { 80 | updateButtons(delta); 81 | 82 | if (playButton.wasPressed()) { 83 | playButtonSound(); 84 | startGame(); 85 | } else if (game.canShowScores() && scoresButton.wasPressed()) { 86 | playButtonSound(); 87 | showScores(); 88 | } else { 89 | Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 90 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 91 | spriteBatch.begin(); 92 | Assets.scoreFont.setColor(Color.WHITE); 93 | float y = VIRTUAL_HEIGHT - Assets.scoreFont.getCapHeight() / 2.0f; 94 | Assets.scoreFont.drawWrapped(spriteBatch, TITLE, 0, y, VIRTUAL_WIDTH, HAlignment.CENTER); 95 | Assets.textFont.drawWrapped(spriteBatch, JIBBER_JABBER, VIRTUAL_WIDTH / 8, 3 * VIRTUAL_HEIGHT / 4, 96 | 3 * VIRTUAL_WIDTH / 4, HAlignment.CENTER); 97 | drawButtons(); 98 | spriteBatch.end(); 99 | } 100 | } 101 | 102 | private void playButtonSound () { 103 | Sound buttonPressedSound = Assets.buttonSound; 104 | Assets.playSound(buttonPressedSound); 105 | } 106 | 107 | private void startGame () { 108 | game.setScreen(game.playingScreen); 109 | } 110 | 111 | private void showScores () { 112 | game.showScores(); 113 | } 114 | 115 | private void updateButtons (float delta) { 116 | touchPoint = screenToViewport(Gdx.input.getX(), Gdx.input.getY()); 117 | boolean justTouched = Gdx.input.justTouched(); 118 | boolean isTouched = Gdx.input.isTouched(); 119 | boolean justReleased = wasTouched && !isTouched; 120 | wasTouched = isTouched; 121 | playButton.update(delta, justTouched, isTouched, justReleased, touchPoint.x, touchPoint.y); 122 | if (game.canShowScores()) { 123 | scoresButton.update(delta, justTouched, isTouched, justReleased, touchPoint.x, touchPoint.y); 124 | } 125 | } 126 | 127 | private void drawButtons () { 128 | playButton.draw(spriteBatch); 129 | if (game.canShowScores()) { 130 | scoresButton.draw(spriteBatch); 131 | } 132 | } 133 | 134 | private Vector3 screenToViewport (float x, float y) { 135 | menuCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); 136 | return touchPoint; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/GameObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | import com.badlydrawngames.general.Colliders; 18 | import com.badlydrawngames.general.CollisionGeometry; 19 | 20 | /** All game objects are ultimately based on GameObject. Different behaviours are specified by overriding 21 | * {@link GameObject#update}. 22 | * 23 | * @author Rod */ 24 | public class GameObject { 25 | 26 | /** The default state for any new game object. */ 27 | public static final int INACTIVE = -1; 28 | 29 | /** This game object's x coordinate in world space. */ 30 | public float x; 31 | 32 | /** This game object's y coordinate in world space. */ 33 | public float y; 34 | 35 | /** This game object's width in world units. */ 36 | public float width; 37 | 38 | /** This game object's height in world units. */ 39 | public float height; 40 | 41 | /** This game object's collision geometry (if it has any) in local coordinates. */ 42 | public CollisionGeometry geometry; 43 | 44 | /** This game object's current state. */ 45 | public int state; 46 | 47 | /** How long this game object has been in its current state (in seconds). */ 48 | public float stateTime; 49 | 50 | /** Will be true if this game object is in collision. */ 51 | public boolean inCollision; 52 | 53 | // Holds this game object's bounding rectangle in world space. 54 | private final Rectangle bounds; 55 | 56 | public GameObject () { 57 | stateTime = 0.0f; 58 | inCollision = false; 59 | bounds = new Rectangle(); 60 | } 61 | 62 | /** Assigns collision geometry to this GameObject. 63 | * @param geometry the new collision geometry. */ 64 | public void setGeometry (CollisionGeometry geometry) { 65 | this.geometry = geometry; 66 | } 67 | 68 | /** Returns this GameObject's bounding rectangle. 69 | * @return the bounding rectangle. */ 70 | public Rectangle bounds () { 71 | bounds.x = x; 72 | bounds.y = y; 73 | bounds.width = width; 74 | bounds.height = height; 75 | return bounds; 76 | } 77 | 78 | /** Switches this game object into a new state and resets {@link #stateTime}. 79 | * @param state the new state. */ 80 | public void setState (int state) { 81 | this.state = state; 82 | stateTime = 0.0f; 83 | } 84 | 85 | /** Returns true if this game object's bounds intersect with the given rectangle. 86 | * 87 | * @param r the rectangle to intersect. 88 | * @return true if the bounds intersect. */ 89 | public boolean boundsIntersect (Rectangle r) { 90 | return Colliders.intersects(bounds(), r); 91 | } 92 | 93 | /** Returns true if this game object's bounds intersect with the given game object. 94 | * 95 | * @param go the other game object. 96 | * @return true if the bounds intersect. */ 97 | public boolean boundsIntersect (GameObject go) { 98 | return Colliders.intersects(bounds(), go.bounds()); 99 | } 100 | 101 | /** Returns true if this game object's collision geometry intersects with the given rectangle. 102 | * 103 | * @param r the rectangle to intersect. 104 | * @return true if the geometry intersects with the rectangle. */ 105 | public boolean geometryIntersects (Rectangle r) { 106 | return geometry.intersects(r, x, y); 107 | } 108 | 109 | /** Returns true if this game object's collision geometry intersects with another game object's collision geometry. 110 | * 111 | * @param go the other game object. 112 | * @return true if the geometries intersect. */ 113 | public boolean geometryIntersects (GameObject go) { 114 | return geometry.intersects(x, y, go.geometry, go.x, go.y); 115 | } 116 | 117 | /** Returns true if this game object is in collision with a rectangle. It first does a simple box test against this game 118 | * object's bounds, then, if that's true, tests its collision geometry against the rectangle. 119 | * 120 | * @param r the rectangle to intersect. 121 | * @return true if this game object intersects the rectangle. */ 122 | public boolean intersects (Rectangle r) { 123 | return boundsIntersect(r) && (geometry == null || geometryIntersects(r)); 124 | } 125 | 126 | /** Returns true if this game object is in collision with another game object. It first does a bounds test, then, if that's 127 | * true, tests its collision geometry against the other game object's collision geometry. */ 128 | public boolean intersects (GameObject go) { 129 | if (!boundsIntersect(go)) { 130 | return false; 131 | } 132 | if (geometry == null) { 133 | return go.geometry == null || go.geometryIntersects(bounds()); 134 | } else if (go.geometry == null) { 135 | return geometryIntersects(go.bounds()); 136 | } 137 | return geometryIntersects(go); 138 | } 139 | 140 | /** Updates this game object. Typically you would override this to create interesting behaviour. 141 | * 142 | * @param delta time in seconds since the last update. */ 143 | public void update (float delta) { 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/WorldPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.Gdx; 17 | import com.badlogic.gdx.Input; 18 | import com.badlogic.gdx.graphics.GL20; 19 | import com.badlydrawngames.general.GameScreen; 20 | import com.badlydrawngames.veryangryrobots.WorldView.Presenter; 21 | import com.badlydrawngames.veryangryrobots.mobiles.Player; 22 | 23 | /**

24 | * It is the role of the WorldPresenter to glue together the {@link World} and the {@link WorldView}. It passes on 25 | * information from the controls in the WorldView to the World, updates it, then asks the WorldView to draw everything on its 26 | * behalf. The {@link WorldView} tells this WorldPresenter what to do via the methods provided by the 27 | * {@link Presenter} interface. 28 | *

29 | * 30 | * @author Rod */ 31 | public class WorldPresenter extends GameScreen implements WorldView.Presenter, ScoreListener { 32 | 33 | private static final float MAX_DELTA = 0.1f; 34 | 35 | private final World world; 36 | private final WorldView worldView; 37 | private final StatusView statusView; 38 | private final SoundManager soundManager; 39 | private final StatusManager statusManager; 40 | private final ScoreBasedDifficultyManager difficultyManager; 41 | private int score; 42 | private boolean isDead; 43 | private boolean wasBackPressed; 44 | 45 | /** Constructs a new WorldPresenter. 46 | * 47 | * @param game the game, used primarily for switching between screens. */ 48 | public WorldPresenter (VeryAngryRobotsGame game) { 49 | super(game); 50 | difficultyManager = new ScoreBasedDifficultyManager(); 51 | world = new World(difficultyManager); 52 | statusManager = new StatusManager(); 53 | worldView = new WorldView(world, statusManager, this); 54 | statusView = new StatusView(world); 55 | soundManager = new SoundManager(); 56 | statusManager.addScoreListener(statusView); 57 | statusManager.addScoreListener(this); 58 | statusManager.addScoreListener(difficultyManager); 59 | statusManager.addScoreListener(soundManager); 60 | statusManager.addAchievementsListener(statusView); 61 | statusManager.addAchievementsListener(soundManager); 62 | statusManager.addAchievementsListener(game); 63 | world.addWorldListener(soundManager); 64 | world.addWorldListener(statusManager); 65 | } 66 | 67 | @Override 68 | public void show () { 69 | Gdx.input.setCatchBackKey(true); 70 | wasBackPressed = false; 71 | world.reset(); 72 | world.resume(); 73 | } 74 | 75 | @Override 76 | public void pause () { 77 | world.pause(); 78 | } 79 | 80 | @Override 81 | public void resume () { 82 | Gdx.input.setCatchBackKey(true); 83 | world.resume(); 84 | } 85 | 86 | @Override 87 | public void hide () { 88 | Gdx.input.setCatchBackKey(false); 89 | } 90 | 91 | /** Called by libgdx when this screen should render itself. It responds to a request to render by updating the controls, 92 | * updating the world and the managers, then drawing the views. 93 | * 94 | * @param delta the time in seconds since the last time render was called. */ 95 | @Override 96 | public void render (float delta) { 97 | // Update time. 98 | if (delta >= MAX_DELTA) delta = MAX_DELTA; 99 | 100 | // Ask the view to update the controls. 101 | worldView.updateControls(delta); 102 | 103 | // If we're not paused then update the world and the subsystems. 104 | world.update(delta); 105 | if (!world.isPaused()) { 106 | statusManager.update(delta); 107 | worldView.update(delta); 108 | soundManager.update(delta); 109 | } 110 | 111 | // Clear the screen and draw the views. 112 | Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 113 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 114 | worldView.render(delta); 115 | statusView.render(delta); 116 | 117 | if (isDead && world.getState() == World.PLAYING) { 118 | game.submitScore(score); 119 | game.setScreen(game.scoresScreen); 120 | game.scoresScreen.setScore(score); 121 | } 122 | boolean isBackPressed = Gdx.input.isKeyPressed(Input.Keys.BACK); 123 | if (!wasBackPressed && isBackPressed) { 124 | if (!world.isPaused()) { 125 | world.pause(); 126 | } else { 127 | game.setScreen(game.mainMenuScreen); 128 | } 129 | } 130 | wasBackPressed = isBackPressed; 131 | } 132 | 133 | /** Called by the {@link WorldView} when the player wants to move. 134 | * 135 | * @param x the x value of the controller. 136 | * @param y the y value of the controller. */ 137 | @Override 138 | public void setController (float x, float y) { 139 | Player player = world.getPlayer(); 140 | player.setController(x, y); 141 | } 142 | 143 | /** Called by the {@link WorldView} when the player wants to fire. 144 | * 145 | * @param x the x value of the controller. 146 | * @param y the y value of the controller. */ 147 | @Override 148 | public void setFiringController (float x, float y) { 149 | Player player = world.getPlayer(); 150 | world.firePlayerShot.fire(player, x, y); 151 | } 152 | 153 | @Override 154 | public void onScoreChanged (int score) { 155 | this.score = score; 156 | } 157 | 158 | @Override 159 | public void onLivesChanged (int lives) { 160 | isDead = (lives == 0); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/RoomBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | import com.badlogic.gdx.utils.Array; 18 | import com.badlogic.gdx.utils.IntArray; 19 | import com.badlogic.gdx.utils.Pool; 20 | import com.badlydrawngames.general.Pools; 21 | 22 | public class RoomBuilder { 23 | private static final float WALL_WIDTH = World.WALL_WIDTH; 24 | private static final float WALL_HEIGHT = World.WALL_HEIGHT; 25 | private static final float HALF_HEIGHT = WALL_HEIGHT / 2; 26 | private static final float ADJUSTMENT = World.OUTER_WALL_ADJUST; 27 | private static final int MAX_RECTANGLES = 256; 28 | private static final int MAX_DOORS = 4; 29 | private static final int MAX_WALLS = MAX_RECTANGLES - MAX_DOORS; 30 | 31 | private final MazeGenerator mazeGenerator; 32 | private final Pool rectanglePool; 33 | private Array doorRects; 34 | private Array wallRects; 35 | private final int hcells; 36 | private final int vcells; 37 | 38 | public RoomBuilder (int hcells, int vcells) { 39 | this.hcells = hcells; 40 | this.vcells = vcells; 41 | mazeGenerator = new MazeGenerator(hcells, vcells); 42 | rectanglePool = new Pool(MAX_RECTANGLES) { 43 | @Override 44 | protected Rectangle newObject () { 45 | return new Rectangle(); 46 | } 47 | }; 48 | } 49 | 50 | public void build (int doorPosition) { 51 | mazeGenerator.rebuild(doorPosition); 52 | createWallsAndDoors(); 53 | } 54 | 55 | public Array getWalls () { 56 | return wallRects; 57 | } 58 | 59 | public Array getDoors () { 60 | return doorRects; 61 | } 62 | 63 | private void createWallsAndDoors () { 64 | createWalls(); 65 | createDoors(); 66 | } 67 | 68 | private void createWalls () { 69 | IntArray wallDefs = mazeGenerator.getWalls(); 70 | int n = wallDefs.size / 4; 71 | wallRects = Pools.makeArrayFromPool(wallRects, rectanglePool, MAX_WALLS); 72 | for (int i = 0, j = 0; i < n; i++, j += 4) { 73 | Rectangle wallRect = createWall(wallDefs, j); 74 | wallRects.add(wallRect); 75 | } 76 | } 77 | 78 | private void createDoors () { 79 | IntArray doorDefs = mazeGenerator.getDoors(); 80 | int n = doorDefs.size / 4; 81 | doorRects = Pools.makeArrayFromPool(doorRects, rectanglePool, MAX_DOORS); 82 | for (int i = 0, j = 0; i < n; i++, j += 4) { 83 | Rectangle doorRect = createDoor(doorDefs, j); 84 | doorRects.add(doorRect); 85 | } 86 | } 87 | 88 | private Rectangle createWall (IntArray wallDefs, int i) { 89 | int x1 = wallDefs.get(i); 90 | int y1 = wallDefs.get(i + 1); 91 | int x2 = wallDefs.get(i + 2); 92 | int y2 = wallDefs.get(i + 3); 93 | return (x1 == x2) ? createVWall(x1, y1, y2) : createHWall(x1, x2, y1); 94 | } 95 | 96 | private Rectangle createHWall (int x1, int x2, int y1) { 97 | float x = coordMinusHalfHeight(x1, hcells); 98 | float y = coordMinusHalfHeight(y1, vcells); 99 | float t = coordMinusHalfHeight(x2, hcells); 100 | float w = (t - x) + WALL_HEIGHT; 101 | float h = WALL_HEIGHT; 102 | return newRectangle(x, y, w, h); 103 | } 104 | 105 | private Rectangle createVWall (int x1, int y1, int y2) { 106 | float x = coordMinusHalfHeight(x1, hcells); 107 | float y = coordMinusHalfHeight(y1, vcells); 108 | float t = coordMinusHalfHeight(y2, vcells); 109 | float w = WALL_HEIGHT; 110 | float h = (t - y) + WALL_HEIGHT; 111 | return newRectangle(x, y, w, h); 112 | } 113 | 114 | private Rectangle createDoor (IntArray doorDefs, int i) { 115 | int x1 = doorDefs.get(i); 116 | int y1 = doorDefs.get(i + 1); 117 | int x2 = doorDefs.get(i + 2); 118 | return (x1 == x2) ? createVDoor(x1, y1) : createHDoor(x1, y1); 119 | } 120 | 121 | private Rectangle createHDoor (int x1, int y1) { 122 | float x = coordPlusHalfHeight(x1, hcells); 123 | float y = coordMinusHalfHeight(y1, vcells); 124 | float w = WALL_WIDTH - WALL_HEIGHT; 125 | float h = WALL_HEIGHT; 126 | return newRectangle(x, y, w, h); 127 | } 128 | 129 | private Rectangle createVDoor (int x1, int y1) { 130 | float x = coordMinusHalfHeight(x1, hcells); 131 | float y = coordPlusHalfHeight(y1, vcells); 132 | float w = WALL_HEIGHT; 133 | float h = WALL_WIDTH - WALL_HEIGHT; 134 | return newRectangle(x, y, w, h); 135 | } 136 | 137 | private float coordPlusHalfHeight (int c, int limit) { 138 | float n = ADJUSTMENT; 139 | if (c == 0) { 140 | return n + HALF_HEIGHT; 141 | } else if (c < limit) { 142 | return n + WALL_WIDTH - ADJUSTMENT + ((c - 1) * WALL_WIDTH) + HALF_HEIGHT; 143 | } else { 144 | return n + 2 * (WALL_WIDTH - ADJUSTMENT) + ((c - 2) * WALL_WIDTH) + HALF_HEIGHT; 145 | } 146 | } 147 | 148 | private float coordMinusHalfHeight (int c, int limit) { 149 | float n = ADJUSTMENT; 150 | if (c == 0) { 151 | return n - HALF_HEIGHT; 152 | } else if (c < limit) { 153 | return n + WALL_WIDTH - ADJUSTMENT + ((c - 1) * WALL_WIDTH) - HALF_HEIGHT; 154 | } else { 155 | return n + 2 * (WALL_WIDTH - ADJUSTMENT) + ((c - 2) * WALL_WIDTH) - HALF_HEIGHT; 156 | } 157 | } 158 | 159 | private Rectangle newRectangle (float x, float y, float w, float h) { 160 | Rectangle r = rectanglePool.obtain(); 161 | r.x = x; 162 | r.y = y; 163 | r.width = w; 164 | r.height = h; 165 | return r; 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/Colliders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.math.Rectangle; 17 | import com.badlogic.gdx.utils.Array; 18 | import com.badlogic.gdx.utils.Pool; 19 | import com.badlydrawngames.veryangryrobots.mobiles.GameObject; 20 | 21 | /** Functions that are useful for collision detection. 22 | * @author Rod */ 23 | public final class Colliders { 24 | 25 | public static interface RemovalHandler { 26 | void onRemove (T t); 27 | } 28 | 29 | public static interface ColliderHandler { 30 | void onCollision (T t, U u); 31 | } 32 | 33 | public static interface SceneryHandler { 34 | void onCollision (T t, Rectangle r); 35 | } 36 | 37 | private Colliders () { 38 | } 39 | 40 | /** Returns true if two rectangles intersect. 41 | * @param a the first rectangle. 42 | * @param b the second rectangle. 43 | * @return true if the rectangles intersect, otherwise false. */ 44 | public static boolean intersects (Rectangle a, Rectangle b) { 45 | return (a.x + a.width > b.x) && (a.x < b.x + b.width) && (a.y + a.height > b.y) && (a.y < b.y + b.height); 46 | } 47 | 48 | /** Returns true if a rectangle intersects with any rectangles in an array. 49 | * @param a the rectangle. 50 | * @param rects the array of rectangles. 51 | * @return true if they intersect, otherwise false. */ 52 | public static boolean intersects (Rectangle a, Array rects) { 53 | for (int i = rects.size - 1; i >= 0; i--) { 54 | Rectangle b = rects.get(i); 55 | if (intersects(a, b)) { 56 | return true; 57 | } 58 | } 59 | return false; 60 | } 61 | 62 | public static void collide (T a, U b, 63 | ColliderHandler callback) { 64 | if (a != b) { 65 | if (a.intersects(b)) { 66 | callback.onCollision(a, b); 67 | } 68 | } 69 | } 70 | 71 | public static void collide (T go, Array gos, 72 | ColliderHandler callback) { 73 | for (int i = gos.size - 1; i >= 0; i--) { 74 | U other = gos.get(i); 75 | if (go.intersects(other)) { 76 | callback.onCollision(go, other); 77 | } 78 | } 79 | } 80 | 81 | public static void collide (Array a, ColliderHandler callback) { 82 | for (int i = a.size - 1; i >= 0; i--) { 83 | T go = a.get(i); 84 | for (int j = i - 1; j >= 0; j--) { 85 | T other = a.get(j); 86 | if (go.intersects(other)) { 87 | callback.onCollision(go, other); 88 | } 89 | } 90 | } 91 | } 92 | 93 | @SuppressWarnings("unchecked") 94 | public static void collide (Array a, Array b, 95 | ColliderHandler callback) { 96 | if (a != b) { 97 | for (int i = a.size - 1; i >= 0; i--) { 98 | T go = a.get(i); 99 | collide(go, b, callback); 100 | } 101 | } else { 102 | collide(a, (ColliderHandler)callback); 103 | } 104 | } 105 | 106 | public static void collide (Array gos, Array rects, 107 | SceneryHandler callback) { 108 | for (int i = gos.size - 1; i >= 0; i--) { 109 | T go = gos.get(i); 110 | collide(go, rects, callback); 111 | } 112 | } 113 | 114 | public static void collide (T go, Array rects, SceneryHandler callback) { 115 | for (int i = 0; i < rects.size && !go.inCollision; i++) { 116 | Rectangle r = rects.get(i); 117 | if (go.intersects(r)) { 118 | callback.onCollision(go, r); 119 | } 120 | } 121 | } 122 | 123 | /** Removes game objects that are marked as in collision, calling a removal handler for each one that is marked. Note that the 124 | * "U extends T" part of this method's signature means, for example, that PlayerShot and RobotShot can both have the same 125 | * handler if they are both derived from BaseShot. 126 | * 127 | * @param the base class of the object. 128 | * @param a more specific class of the object. 129 | * @param pool the pool to which the object belongs. 130 | * @param gos the array of game objects to check. 131 | * @param handler the collision handler callback. */ 132 | public static void removeMarkedCollisions (Pool pool, Array gos, 133 | RemovalHandler handler) { 134 | // The "U extends T" allows for shotHandler to cope with both PlayerShot and RobotShot, because they both 135 | // extend BaseShot. 136 | for (int i = gos.size - 1; i >= 0; i--) { 137 | U go = gos.get(i); 138 | if (go.inCollision) { 139 | handler.onRemove(go); 140 | gos.removeIndex(i); 141 | pool.free(go); 142 | } 143 | } 144 | } 145 | 146 | /** Removes game objects that are outside of the given rectangular bounds. 147 | * @param the object's class. 148 | * @param pool the pool to which the object belongs. 149 | * @param gos the array of game objects to check. 150 | * @param bounds the rectangular bounds. */ 151 | public static void removeOutOfBounds (Pool pool, Array gos, Rectangle bounds) { 152 | float minX = bounds.x; 153 | float maxX = minX + bounds.width; 154 | float minY = bounds.y; 155 | float maxY = minY + bounds.height; 156 | for (int i = gos.size - 1; i >= 0; i--) { 157 | T go = gos.get(i); 158 | if (go.x >= maxX || go.x + go.width <= minX || go.y >= maxY || go.y + go.height <= minY) { 159 | gos.removeIndex(i); 160 | pool.free(go); 161 | } 162 | } 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/general/CameraHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.general; 15 | 16 | import com.badlogic.gdx.Gdx; 17 | import com.badlogic.gdx.graphics.OrthographicCamera; 18 | import com.badlogic.gdx.math.Vector2; 19 | 20 | public final class CameraHelper { 21 | 22 | private CameraHelper () { 23 | } 24 | 25 | /** Creates an orthographic camera where the "play area" has the given viewport size. The viewport will either be stretched to 26 | * fill the entire window, or it will be scaled to maintain the aspect ratio. 27 | * 28 | * @param isStretched true if the "play area" is stretched to fill the entire window. 29 | * @param virtualWidth the width of the game screen in virtual pixels. 30 | * @param virtualHeight the height of the game screen in virtual pixels. 31 | * @return the new camera. */ 32 | public static OrthographicCamera createCamera (boolean isStretched, float virtualWidth, float virtualHeight) { 33 | // Get the viewport size. 34 | Vector2 viewportSize = viewportSize(isStretched, virtualWidth, virtualHeight); 35 | float viewportWidth = viewportSize.x; 36 | float viewportHeight = viewportSize.y; 37 | 38 | // Create the camera, placing the origin at the bottom left of the viewport. 39 | OrthographicCamera camera = new OrthographicCamera(viewportWidth, viewportHeight); 40 | float xOrg = (viewportWidth - virtualWidth) / 2; 41 | float yOrg = (viewportHeight - virtualHeight) / 2; 42 | camera.position.set(viewportWidth / 2 - xOrg, viewportHeight / 2 - yOrg, 0); 43 | camera.update(); 44 | return camera; 45 | } 46 | 47 | /** Calculates the dimensions of the viewport required to support the given virtual coordinates. 48 | * 49 | * @param isStretched true if the viewport should be stretched to fill the entire window. 50 | * @param virtualWidth the width of the viewport in virtual units. 51 | * @param virtualHeight the height of the viewport in virtual units. 52 | * @return the viewport's dimensions. */ 53 | public static Vector2 viewportSize (boolean isStretched, float virtualWidth, float virtualHeight) { 54 | float viewportWidth; 55 | float viewportHeight; 56 | if (isStretched) { 57 | // Stretch the camera to fill the entire screen. 58 | viewportWidth = virtualWidth; 59 | viewportHeight = virtualHeight; 60 | } else { 61 | // Maintain the aspect ratio by letterboxing. 62 | float aspect = virtualWidth / virtualHeight; 63 | float physicalWidth = Gdx.graphics.getWidth(); 64 | float physicalHeight = Gdx.graphics.getHeight(); 65 | if (physicalWidth / physicalHeight >= aspect) { 66 | // Letterbox left and right. 67 | viewportHeight = virtualHeight; 68 | viewportWidth = viewportHeight * physicalWidth / physicalHeight; 69 | } else { 70 | // Letterbox above and below. 71 | viewportWidth = virtualWidth; 72 | viewportHeight = viewportWidth * physicalHeight / physicalWidth; 73 | } 74 | } 75 | return new Vector2(viewportWidth, viewportHeight); 76 | } 77 | 78 | public static enum ViewportMode { 79 | PIXEL_PERFECT, STRETCH_TO_ASPECT, STRETCH_TO_SCREEN 80 | } 81 | 82 | public static OrthographicCamera createCamera2 (ViewportMode viewportMode, float virtualWidth, float virtualHeight, 83 | float density) { 84 | // Get the viewport size. 85 | Vector2 viewportSize = sizeToDensity(viewportMode, virtualWidth, virtualHeight, density); 86 | float viewportWidth = viewportSize.x; 87 | float viewportHeight = viewportSize.y; 88 | 89 | // Create the camera, placing the origin at the bottom left of the viewport. 90 | OrthographicCamera camera = new OrthographicCamera(viewportWidth, viewportHeight); 91 | float xOrg = (viewportWidth - virtualWidth) / 2; 92 | float yOrg = (viewportHeight - virtualHeight) / 2; 93 | camera.position.set(viewportWidth / 2 - xOrg, viewportHeight / 2 - yOrg, 0); 94 | camera.update(); 95 | return camera; 96 | } 97 | 98 | public static Vector2 sizeToDensity (ViewportMode viewportMode, float virtualWidth, float virtualHeight, float density) { 99 | float viewportWidth = virtualWidth; 100 | float viewportHeight = virtualHeight; 101 | float physicalWidth = Gdx.graphics.getWidth(); 102 | float physicalHeight = Gdx.graphics.getHeight(); 103 | if (viewportMode == ViewportMode.PIXEL_PERFECT) { 104 | float widthAtDensity = viewportWidth * density; 105 | float heightAtDensity = viewportHeight * density; 106 | viewportWidth *= (physicalWidth / widthAtDensity); 107 | viewportHeight *= (physicalHeight / heightAtDensity); 108 | } else if (viewportMode == ViewportMode.STRETCH_TO_ASPECT) { 109 | float aspect = virtualWidth / virtualHeight; 110 | if (physicalWidth / physicalHeight >= aspect) { 111 | // Letterbox left and right. 112 | viewportHeight = virtualHeight; 113 | viewportWidth = viewportHeight * physicalWidth / physicalHeight; 114 | } else { 115 | // Letterbox above and below. 116 | viewportWidth = virtualWidth; 117 | viewportHeight = viewportWidth * physicalHeight / physicalWidth; 118 | } 119 | } 120 | return new Vector2(viewportWidth, viewportHeight); 121 | } 122 | 123 | public static float bestDensity (float virtualWidth, float virtualHeight, float[] densities) { 124 | // TODO: Spell out that densities is assumed to be in ascending order. 125 | float bestDensity = densities[0]; 126 | float physicalWidth = Gdx.graphics.getWidth(); 127 | float physicalHeight = Gdx.graphics.getHeight(); 128 | for (int i = 1; i < densities.length; i++) { 129 | float density = densities[i]; 130 | float widthAtDensity = density * virtualWidth; 131 | float heightAtDensity = density * virtualHeight; 132 | if (widthAtDensity > physicalWidth || heightAtDensity > physicalHeight) { 133 | break; 134 | } 135 | bestDensity = density; 136 | } 137 | return bestDensity; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/mobiles/Robot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots.mobiles; 15 | 16 | import com.badlogic.gdx.math.Intersector; 17 | import com.badlogic.gdx.math.Rectangle; 18 | import com.badlogic.gdx.math.Vector2; 19 | import com.badlogic.gdx.utils.Array; 20 | import com.badlydrawngames.general.Config; 21 | import com.badlydrawngames.veryangryrobots.Assets; 22 | import com.badlydrawngames.veryangryrobots.World.FireCommand; 23 | 24 | import static com.badlogic.gdx.math.MathUtils.*; 25 | import static com.badlydrawngames.general.MathUtils.*; 26 | 27 | public class Robot extends GameObject { 28 | 29 | public static final int SCANNING = INACTIVE + 1; 30 | public static final int WALKING_RIGHT = SCANNING + 1; 31 | public static final int WALKING_RIGHT_DIAGONAL = WALKING_RIGHT + 1; 32 | public static final int WALKING_LEFT = WALKING_RIGHT_DIAGONAL + 1; 33 | public static final int WALKING_LEFT_DIAGONAL = WALKING_LEFT + 1; 34 | public static final int WALKING_DOWN = WALKING_LEFT_DIAGONAL + 1; 35 | public static final int WALKING_UP = WALKING_DOWN + 1; 36 | 37 | private static final float WALKING_SPEED = Config.asFloat("Robot.speed", 1.25f); 38 | 39 | private GameObject player; 40 | private Array walls; 41 | private final float distance; 42 | private final float fudge; 43 | private FireCommand fireCommand; 44 | private Vector2 firingDirection; 45 | private Vector2 robotPos; 46 | private Vector2 playerPos; 47 | private Vector2 lineStart; 48 | private Vector2 lineEnd; 49 | private float respawnX; 50 | private float respawnY; 51 | 52 | public Robot () { 53 | width = Assets.robotWidth; 54 | height = Assets.robotHeight; 55 | distance = max(width, height); 56 | fudge = distance * 0.25f; 57 | setState(INACTIVE); 58 | firingDirection = new Vector2(); 59 | robotPos = new Vector2(); 60 | playerPos = new Vector2(); 61 | lineStart = new Vector2(); 62 | lineEnd = new Vector2(); 63 | } 64 | 65 | public void setPlayer (GameObject player) { 66 | this.player = player; 67 | } 68 | 69 | public void setWalls (Array walls) { 70 | this.walls = walls; 71 | } 72 | 73 | public void setFireCommand (FireCommand fireCommand) { 74 | this.fireCommand = fireCommand; 75 | } 76 | 77 | @Override 78 | public void update (float delta) { 79 | stateTime += delta; 80 | moveRobot(delta); 81 | if (fireCommand != null && canFire(delta) && canSeePlayer()) { 82 | firingDirection.set(player.x - x, player.y - y); 83 | firingDirection.nor(); 84 | fireCommand.fire(this, firingDirection.x, firingDirection.y); 85 | } 86 | } 87 | 88 | private boolean canFire (float delta) { 89 | // TODO: remove magic numbers, or possibly switch to expovariate randomness. 90 | return random(100) < 50 * delta; 91 | } 92 | 93 | private void moveRobot (float delta) { 94 | float dx = (player.x + player.width / 2) - (x + width / 2); 95 | float dy = (player.y + player.height / 2) - (y + height / 2); 96 | dx = abs(dx) >= 2 ? sgn(dx) : 0.0f; 97 | dy = abs(dy) >= 2 ? sgn(dy) : 0.0f; 98 | float ax = 0.0f; 99 | float ay = 0.0f; 100 | if (!wouldHitWall(dx, dy)) { 101 | ax = dx; 102 | ay = dy; 103 | } else if (dx != 0 && !wouldHitWall(dx, 0)) { 104 | ax = dx; 105 | } else if (dy != 0 && !wouldHitWall(0, dy)) { 106 | ay = dy; 107 | } 108 | dx = ax * WALKING_SPEED; 109 | dy = ay * WALKING_SPEED; 110 | x += dx * delta; 111 | y += dy * delta; 112 | 113 | int newState = getMovementState(dx, dy); 114 | if (newState != state) { 115 | setState(newState); 116 | } 117 | } 118 | 119 | private int getMovementState (float dx, float dy) { 120 | if (dx == 0.0f && dy == 0.0f) { 121 | return SCANNING; 122 | } else if (dx > 0) { 123 | return (dy == 0) ? WALKING_RIGHT : WALKING_RIGHT_DIAGONAL; 124 | } else if (dx < 0) { 125 | return (dy == 0) ? WALKING_LEFT : WALKING_LEFT_DIAGONAL; 126 | } else if (dy < 0) { 127 | return WALKING_DOWN; 128 | } else { 129 | return WALKING_UP; 130 | } 131 | } 132 | 133 | private boolean wouldHitWall (float dx, float dy) { 134 | float x1 = x + width / 2; 135 | float y1 = y + height / 2; 136 | float x2 = x1 + dx * distance; 137 | float y2 = y1 + dy * distance; 138 | 139 | for (int i = 0; i < walls.size; i++) { 140 | Rectangle wall = walls.get(i); 141 | if (doesLineHitWall(wall, x1, y1, x2, y2)) { 142 | return true; 143 | } 144 | } 145 | return false; 146 | } 147 | 148 | private boolean doesLineHitWall (Rectangle rect, float x1, float y1, float x2, float y2) { 149 | // Does not intersect if minimum y coordinate is below the rectangle. 150 | float minY = min(y1, y2); 151 | if (minY >= rect.y + rect.height + fudge) return false; 152 | 153 | // Does not intersect if maximum y coordinate is above the rectangle. 154 | float maxY = max(y1, y2); 155 | if (maxY < rect.y - fudge) return false; 156 | 157 | // Does not intersect if minimum x coordinate is to the right of the rectangle. 158 | float minX = min(x1, x2); 159 | if (minX >= rect.x + rect.width + fudge) return false; 160 | 161 | // Does not intersect if maximum x coordinate is to the left of the rectangle. 162 | float maxX = max(x1, x2); 163 | if (maxX < rect.x - fudge) return false; 164 | 165 | // And that's good enough, because the robots need to be a bit stupid 166 | // when they're near the ends of walls. 167 | return true; 168 | } 169 | 170 | private boolean canSeePlayer () { 171 | return hasLineOfSight(this, player); 172 | } 173 | 174 | private boolean hasLineOfSight (GameObject a, GameObject b) { 175 | return hasLineOfSight(a.x + a.width / 2, a.y + a.height / 2, b.x + b.width / 2, b.y + b.height / 2); 176 | } 177 | 178 | private boolean hasLineOfSight (float x1, float y1, float x2, float y2) { 179 | robotPos.set(x1, y1); 180 | playerPos.set(x2, y2); 181 | for (int i = 0; i < walls.size; i++) { 182 | Rectangle wall = walls.get(i); 183 | if (wall.width > wall.height) { 184 | lineStart.set(wall.x, wall.y + wall.height / 2); 185 | lineEnd.set(wall.x + wall.width, lineStart.y); 186 | } else { 187 | lineStart.set(wall.x + wall.width / 2, wall.y); 188 | lineEnd.set(lineStart.x, wall.y + wall.height); 189 | } 190 | if (Intersector.intersectSegments(robotPos, playerPos, lineStart, lineEnd, null)) { 191 | return false; 192 | } 193 | } 194 | return true; 195 | } 196 | 197 | public void setRespawnPoint (float x, float y) { 198 | respawnX = x; 199 | respawnY = y; 200 | } 201 | 202 | public void respawn () { 203 | x = respawnX; 204 | y = respawnY; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/ScoreBasedDifficultyManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | import com.badlydrawngames.general.Config; 18 | 19 | public class ScoreBasedDifficultyManager implements DifficultyManager, ScoreListener { 20 | 21 | // Robot numbers. 22 | private static final int MAX_ROBOTS = Config.asInt("Global.maxRobots", 12); 23 | private static final int INITIAL_ROBOTS = Config.asInt("Global.initialRobots", 6); 24 | 25 | // Shot speeds. 26 | private static final float SLOW_SHOT_SPEED = Config.asFloat("RobotShot.slowSpeed", 75.0f); 27 | private static final float FAST_SHOT_SPEED = Config.asFloat("RobotShot.fastSpeed", 125.0f); 28 | 29 | // Level progression. 30 | private static final int ROBOT_INCREMENT = Config.asInt("Level.robotIncrement", 3); 31 | private static final int LEVEL_0_ROBOT_SHOTS = Config.asInt("Level.0.robotShots", 0); 32 | private static final int LEVEL_1_ROBOT_SHOTS = Config.asInt("Level.1.robotShots", 1); 33 | private static final int LEVEL_2_ROBOT_SHOTS = Config.asInt("Level.2.robotShots", 2); 34 | private static final int LEVEL_3_ROBOT_SHOTS = Config.asInt("Level.3.robotShots", 3); 35 | private static final int LEVEL_4_ROBOT_SHOTS = Config.asInt("Level.4.robotShots", 4); 36 | private static final int LEVEL_5_ROBOT_SHOTS = Config.asInt("Level.5.robotShots", 5); 37 | private static final int LEVEL_6_ROBOT_SHOTS = Config.asInt("Level.6.robotShots", 1); 38 | private static final int LEVEL_7_ROBOT_SHOTS = Config.asInt("Level.7.robotShots", 2); 39 | private static final int LEVEL_8_ROBOT_SHOTS = Config.asInt("Level.8.robotShots", 3); 40 | private static final int LEVEL_9_ROBOT_SHOTS = Config.asInt("Level.9.robotShots", 4); 41 | private static final int LEVEL_10_ROBOT_SHOTS = Config.asInt("Level.10.robotShots", 5); 42 | private static final int LEVEL_11_ROBOT_SHOTS = Config.asInt("Level.11.robotShots", 6); 43 | private static final int LEVEL_1_SCORE = Config.asInt("Level.1.score", 200); 44 | private static final int LEVEL_2_SCORE = Config.asInt("Level.2.score", 500); 45 | private static final int LEVEL_3_SCORE = Config.asInt("Level.3.score", 1000); 46 | private static final int LEVEL_4_SCORE = Config.asInt("Level.4.score", 2500); 47 | private static final int LEVEL_5_SCORE = Config.asInt("Level.5.score", 5000); 48 | private static final int LEVEL_6_SCORE = Config.asInt("Level.6.score", 7500); 49 | private static final int LEVEL_7_SCORE = Config.asInt("Level.7.score", 10000); 50 | private static final int LEVEL_8_SCORE = Config.asInt("Level.8.score", 12500); 51 | private static final int LEVEL_9_SCORE = Config.asInt("Level.9.score", 15000); 52 | private static final int LEVEL_10_SCORE = Config.asInt("Level.10.score", 17500); 53 | private static final int LEVEL_11_SCORE = Config.asInt("Level.11.score", 20000); 54 | 55 | // Robot colours. 56 | private static final Color DARK_YELLOW = new Color(0.75f, 0.75f, 0.0f, 1.0f); 57 | private static final Color RED = Color.RED; 58 | private static final Color DARK_CYAN = new Color(0.0f, 0.75f, 0.75f, 1.0f); 59 | private static final Color GREEN = Color.GREEN; 60 | private static final Color DARK_PURPLE = new Color(0.75f, 0.0f, 0.75f, 1.0f); 61 | private static final Color LIGHT_YELLOW = new Color(1.0f, 1.0f, 0.0f, 1.0f); 62 | private static final Color WHITE = Color.WHITE; 63 | private static final Color LIGHT_PURPLE = new Color(1.0f, 0.0f, 1.0f, 1.0f); 64 | private static final Color GREY = new Color(0.75f, 0.75f, 0.75f, 1.0f); 65 | 66 | private boolean dirty; 67 | private int score; 68 | private Color robotColor; 69 | private int numRobots; 70 | private int numRobotShots; 71 | private float robotShotSpeed; 72 | 73 | @Override 74 | public Color getRobotColor () { 75 | updateIfDirty(); 76 | return robotColor; 77 | } 78 | 79 | @Override 80 | public int getNumberOfRobots () { 81 | updateIfDirty(); 82 | return numRobots; 83 | } 84 | 85 | @Override 86 | public int getNumberOfRobotShots () { 87 | updateIfDirty(); 88 | return numRobotShots; 89 | } 90 | 91 | @Override 92 | public float getRobotShotSpeed () { 93 | updateIfDirty(); 94 | return robotShotSpeed; 95 | } 96 | 97 | @Override 98 | public void onScoreChanged (int score) { 99 | dirty = true; 100 | this.score = score; 101 | } 102 | 103 | @Override 104 | public void onLivesChanged (int lives) { 105 | } 106 | 107 | private void updateIfDirty () { 108 | if (!dirty) return; 109 | dirty = false; 110 | 111 | Color lastRobotColor = robotColor; 112 | if (score < LEVEL_1_SCORE) { 113 | robotColor = DARK_YELLOW; 114 | numRobotShots = LEVEL_0_ROBOT_SHOTS; 115 | robotShotSpeed = SLOW_SHOT_SPEED; 116 | } else if (score < LEVEL_2_SCORE) { 117 | robotColor = RED; 118 | numRobotShots = LEVEL_1_ROBOT_SHOTS; 119 | robotShotSpeed = SLOW_SHOT_SPEED; 120 | } else if (score < LEVEL_3_SCORE) { 121 | robotColor = DARK_CYAN; 122 | numRobotShots = LEVEL_2_ROBOT_SHOTS; 123 | robotShotSpeed = SLOW_SHOT_SPEED; 124 | } else if (score < LEVEL_4_SCORE) { 125 | robotColor = GREEN; 126 | numRobotShots = LEVEL_3_ROBOT_SHOTS; 127 | robotShotSpeed = SLOW_SHOT_SPEED; 128 | } else if (score < LEVEL_5_SCORE) { 129 | robotColor = DARK_PURPLE; 130 | numRobotShots = LEVEL_4_ROBOT_SHOTS; 131 | robotShotSpeed = SLOW_SHOT_SPEED; 132 | } else if (score < LEVEL_6_SCORE) { 133 | robotColor = LIGHT_YELLOW; 134 | numRobotShots = LEVEL_5_ROBOT_SHOTS; 135 | robotShotSpeed = SLOW_SHOT_SPEED; 136 | } else if (score < LEVEL_7_SCORE) { 137 | robotColor = WHITE; 138 | numRobotShots = LEVEL_6_ROBOT_SHOTS; 139 | robotShotSpeed = FAST_SHOT_SPEED; 140 | } else if (score < LEVEL_8_SCORE) { 141 | robotColor = DARK_CYAN; 142 | numRobotShots = LEVEL_7_ROBOT_SHOTS; 143 | robotShotSpeed = FAST_SHOT_SPEED; 144 | } else if (score < LEVEL_9_SCORE) { 145 | robotColor = LIGHT_PURPLE; 146 | numRobotShots = LEVEL_8_ROBOT_SHOTS; 147 | robotShotSpeed = FAST_SHOT_SPEED; 148 | } else if (score < LEVEL_10_SCORE) { 149 | robotColor = GREY; 150 | numRobotShots = LEVEL_9_ROBOT_SHOTS; 151 | robotShotSpeed = FAST_SHOT_SPEED; 152 | } else if (score < LEVEL_11_SCORE) { 153 | robotColor = DARK_YELLOW; 154 | numRobotShots = LEVEL_10_ROBOT_SHOTS; 155 | robotShotSpeed = FAST_SHOT_SPEED; 156 | } else { 157 | robotColor = RED; 158 | numRobotShots = LEVEL_11_ROBOT_SHOTS; 159 | robotShotSpeed = FAST_SHOT_SPEED; 160 | } 161 | 162 | if (lastRobotColor == robotColor && score >= LEVEL_1_SCORE) { 163 | if (numRobots < MAX_ROBOTS) { 164 | numRobots += ROBOT_INCREMENT; 165 | } 166 | } else { 167 | numRobots = INITIAL_ROBOTS; 168 | } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /core/src/com/badlydrawngames/veryangryrobots/StatusManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Rod Hyde (rod@badlydrawngames.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the 5 | * License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 10 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | */ 13 | 14 | package com.badlydrawngames.veryangryrobots; 15 | 16 | import java.util.EnumSet; 17 | 18 | import com.badlogic.gdx.Gdx; 19 | import com.badlydrawngames.general.Config; 20 | import com.badlydrawngames.veryangryrobots.mobiles.BaseShot; 21 | import com.badlydrawngames.veryangryrobots.mobiles.Robot; 22 | 23 | public class StatusManager implements WorldListener { 24 | 25 | public enum Achievements { 26 | PERFECTIONIST("Perfectionist", "Clear " + CLEAN_ROOMS + " rooms in a row."), PERFECT_SHOT("Perfect Shot", 27 | "Clear a room by shooting everything."), PACIFICIST("Pacifist", "Clear a room without shooting anything."), DAREDEVIL( 28 | "Daredevil", "Survive for " + DAREDEVIL_SECONDS + " seconds after the captain enters the room."), COWARD("Coward", 29 | "Run from " + CHICKEN_ROOMS + " rooms in a row."), ADDICT("Addict", "Play " + ADDICT_GAMES + " games."), LUCKY_JIM( 30 | "Lucky Jim", "Survive for " + LUCKY_JIM_ROOMS + " rooms without being hit."), ROBOCIDE("Robocide", "Destroyed " 31 | + ROBOCIDE_ROBOTS + " robots"); 32 | 33 | private final String summary; 34 | private final String text; 35 | 36 | private Achievements (String summary, String text) { 37 | this.summary = summary; 38 | this.text = text; 39 | } 40 | 41 | public String summary () { 42 | return this.summary; 43 | } 44 | 45 | public String text () { 46 | return this.text; 47 | } 48 | } 49 | 50 | // Achievements. 51 | static final int CLEAN_ROOMS = Config.asInt("achievements.cleanRoomsForPerfectionist", 5); 52 | static final int ROBOCIDE_ROBOTS = Config.asInt("achievements.robotsForRobocide", 50); 53 | static final int LUCKY_JIM_ROOMS = Config.asInt("achievements.roomsForLuckyJim", 10); 54 | static final int CHICKEN_ROOMS = Config.asInt("achievements.roomsForChicken", 5); 55 | static final int ADDICT_GAMES = Config.asInt("achievements.gamesForAddict", 5); 56 | static final float DAREDEVIL_SECONDS = Config.asInt("achievements.daredevilSeconds", 10); 57 | 58 | // Lives and scoring. 59 | private static final int INITIAL_LIVES = Config.asInt("Player.lives", 3); 60 | private static final int ROBOT_SCORE = Config.asInt("Robot.score", 50); 61 | private static final int ROBOT_BONUS_SCORE = Config.asInt("Robot.bonusScore", 100); 62 | private static final int EXTRA_LIFE_SCORE_1 = Config.asInt("Player.firstExtraLife", 10000); 63 | private static final int EXTRA_LIFE_SCORE_2 = Config.asInt("Player.secondExtraLife", 50000); 64 | 65 | private final ScoreNotifier scoreNotifier; 66 | private final ScoringEventNotifier scoringEventNotifier; 67 | private final AchievementsNotifier achievementsNotifier; 68 | private final EnumSet achieved; 69 | 70 | /** The number of lives that the player has. */ 71 | private int lives; 72 | 73 | /** The player's score. */ 74 | private int score; 75 | 76 | /** The number of games that the player has played. */ 77 | private int numGames; 78 | 79 | /** The number of robots that have been shot in this room. */ 80 | private int robotsShot; 81 | 82 | /** The number of robots that have been destroyed in this room (including those that have been shot). */ 83 | private int robotsDestroyed; 84 | 85 | /** The number of times the player has been hit in this room. */ 86 | private int playerHits; 87 | 88 | /** The number of robots that have been destroyed in this game (including those that have been shot). */ 89 | private int gameRobotsDestroyed; 90 | 91 | /** The number of times the player has cleared a room in a row. */ 92 | private int cleanRooms; 93 | 94 | /** The number of rooms that the player has got through without dying. */ 95 | private int gameRoomsWithoutDying; 96 | 97 | /** The number of robots in the room. */ 98 | private int numRobots; 99 | 100 | /** The number of times the player has fled from a room in a row. */ 101 | private int chickenRooms; 102 | 103 | /** The time at which the daredevil achievement is fired. */ 104 | private float daredevilTime; 105 | 106 | /** True if the player was hit. */ 107 | private boolean isPlayerHit; 108 | 109 | private float now; 110 | 111 | public StatusManager () { 112 | scoreNotifier = new ScoreNotifier(); 113 | achievementsNotifier = new AchievementsNotifier(); 114 | scoringEventNotifier = new ScoringEventNotifier(); 115 | achieved = EnumSet.noneOf(Achievements.class); 116 | } 117 | 118 | public void update (float delta) { 119 | now += delta; 120 | if (daredevilTime != 0.0f && now >= daredevilTime) { 121 | achievement(Achievements.DAREDEVIL); 122 | daredevilTime = 0.0f; 123 | } 124 | } 125 | 126 | public void addScoreListener (ScoreListener listener) { 127 | scoreNotifier.addListener(listener); 128 | } 129 | 130 | public void addAchievementsListener (AchievementsListener listener) { 131 | achievementsNotifier.addListener(listener); 132 | } 133 | 134 | public void addScoringEventListener (ScoringEventListener listener) { 135 | scoringEventNotifier.addListener(listener); 136 | } 137 | 138 | private void setLives (int lives) { 139 | this.lives = lives; 140 | scoreNotifier.onLivesChanged(lives); 141 | } 142 | 143 | private void addLives (int inc) { 144 | setLives(lives + inc); 145 | } 146 | 147 | private void setScore (int newScore) { 148 | this.score = newScore; 149 | scoreNotifier.onScoreChanged(newScore); 150 | } 151 | 152 | private void addScore (int inc) { 153 | int oldScore = score; 154 | setScore(score + inc); 155 | if (oldScore < EXTRA_LIFE_SCORE_1 && score >= EXTRA_LIFE_SCORE_1) { 156 | addLives(1); 157 | } else if (oldScore < EXTRA_LIFE_SCORE_2 && score >= EXTRA_LIFE_SCORE_2) { 158 | addLives(1); 159 | } 160 | } 161 | 162 | @Override 163 | public void onWorldReset () { 164 | numGames++; 165 | achieved.clear(); 166 | if (numGames == ADDICT_GAMES) { 167 | achievement(Achievements.ADDICT); 168 | } 169 | gameRobotsDestroyed = 0; 170 | gameRoomsWithoutDying = 0; 171 | cleanRooms = 0; 172 | chickenRooms = 0; 173 | isPlayerHit = false; 174 | now = 0.0f; 175 | setLives(INITIAL_LIVES); 176 | setScore(0); 177 | } 178 | 179 | @Override 180 | public void onEnteredRoom (float time, int robots) { 181 | robotsShot = 0; 182 | robotsDestroyed = 0; 183 | playerHits = 0; 184 | daredevilTime = 0.0f; 185 | numRobots = robots; 186 | } 187 | 188 | @Override 189 | public void onExitedRoom (float time, int robots) { 190 | if (robots == 0) { 191 | chickenRooms = 0; 192 | cleanRooms++; 193 | if (cleanRooms == CLEAN_ROOMS) { 194 | achievement(Achievements.PERFECTIONIST); 195 | } else if (robotsShot == 0) { 196 | achievement(Achievements.PACIFICIST); 197 | } 198 | } else { 199 | cleanRooms = 0; 200 | chickenRooms++; 201 | if (chickenRooms == CHICKEN_ROOMS) { 202 | achievement(Achievements.COWARD); 203 | } 204 | } 205 | if (playerHits == 0) { 206 | gameRoomsWithoutDying++; 207 | if (gameRoomsWithoutDying == LUCKY_JIM_ROOMS) { 208 | achievement(Achievements.LUCKY_JIM); 209 | } 210 | } else { 211 | gameRoomsWithoutDying = 0; 212 | } 213 | Gdx.app.log("Metrics", "FPS = " + Gdx.graphics.getFramesPerSecond()); 214 | } 215 | 216 | @Override 217 | public void onRobotHit (Robot robot) { 218 | robotsShot++; 219 | if (robotsShot == numRobots) { 220 | achievement(Achievements.PERFECT_SHOT); 221 | } 222 | } 223 | 224 | @Override 225 | public void onRobotDestroyed (Robot robot) { 226 | robotsDestroyed++; 227 | gameRobotsDestroyed++; 228 | int robotScore = ROBOT_SCORE; 229 | if (robotsDestroyed == numRobots) { 230 | robotScore += ROBOT_BONUS_SCORE; 231 | } 232 | addScore(robotScore); 233 | scoringEventNotifier.onScoringEvent(robot.x + robot.width / 2, robot.y + robot.height / 2, robotScore); 234 | if (gameRobotsDestroyed == ROBOCIDE_ROBOTS) { 235 | achievement(Achievements.ROBOCIDE); 236 | } 237 | } 238 | 239 | @Override 240 | public void onPlayerHit () { 241 | daredevilTime = 0.0f; 242 | playerHits++; 243 | isPlayerHit = true; 244 | } 245 | 246 | @Override 247 | public void onCaptainActivated (float time) { 248 | daredevilTime = now + DAREDEVIL_SECONDS; 249 | } 250 | 251 | @Override 252 | public void onPlayerFired () { 253 | } 254 | 255 | @Override 256 | public void onPlayerSpawned () { 257 | if (isPlayerHit) { 258 | addLives(-1); 259 | isPlayerHit = false; 260 | } 261 | } 262 | 263 | @Override 264 | public void onRobotFired (Robot robot) { 265 | } 266 | 267 | @Override 268 | public void onShotDestroyed (BaseShot shot) { 269 | } 270 | 271 | private void achievement (Achievements achievement) { 272 | if (!achieved.contains(achievement)) { 273 | achieved.add(achievement); 274 | achievementsNotifier.onAttained(achievement); 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /core/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /android/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS --------------------------------------------------------------------------------