Back to project page Avoidance.
The source code is released under:
GNU General Public License
If you think the Android project Avoidance listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (c) 2012 Jakob Svensson/* ww w .j av a 2s .c om*/ * * This file is part of Avoidance. * * Avoidance is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Avoidance is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Avoidance. If not, see <http://www.gnu.org/licenses/>. * */ package se.chalmers.avoidance.core.collisionhandlers; import se.chalmers.avoidance.constants.GameConstants; import se.chalmers.avoidance.core.components.Jump; import com.artemis.ComponentMapper; import com.artemis.Entity; import com.artemis.World; import com.artemis.managers.GroupManager; /** * Handles collision between player and killplayerobstacles. * * @author Jakob Svensson * */ public class KillplayerobstacleCollisionHandler implements CollisionHandler { private World world; /** * Construct a new KillplayerobstacleCollisionHandler. * * @param world * the world object */ public KillplayerobstacleCollisionHandler(World world) { this.world = world; } /** * Handles collision between player and killplayerobstacles. * * @param player * the player * @param obstacle * the killplayerobstacle */ public void handleCollision(Entity player, Entity obstacle) { GroupManager groupManager = world.getManager(GroupManager.class); if (groupManager.getEntities(GameConstants.GROUP_PLAYER).contains( player) && groupManager .getEntities(GameConstants.GROUP_OBSTACLE_SPIKES) .contains(obstacle)) { ComponentMapper<Jump> jumpMapper = world.getMapper(Jump.class); Jump jump = jumpMapper.get(player); if (jump == null || !jump.isInTheAir()) { GameOverNotifier.getInstance().gameOver(); } } } }