PageRenderTime 992ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/org.jfge.android/src/org/jfge/android/SfVsMk2.java

http://java-fighting-game-engine.googlecode.com/
Java | 149 lines | 91 code | 21 blank | 37 comment | 0 complexity | 87290b82be6c096fa0b7ce2c3db7a1cf MD5 | raw file
  1. package org.jfge.android;
  2. import java.util.Map;
  3. import org.jfge.android.graphics.AndroidGraphicsModule;
  4. import org.jfge.api.ai.AiModule;
  5. import org.jfge.api.arena.ArenaModule;
  6. import org.jfge.api.collision.CollisionModule;
  7. import org.jfge.api.effect.EffectModule;
  8. import org.jfge.api.engine.EngineModule;
  9. import org.jfge.api.fighter.FighterModule;
  10. import org.jfge.api.game.Game;
  11. import org.jfge.api.game.GameModule;
  12. import org.jfge.api.projectile.ProjectileModule;
  13. import org.jfge.api.render.RenderModule;
  14. import org.jfge.ext.physics.PhysicsModule;
  15. import org.jfge.ext.scene.SceneModule;
  16. import org.jfge.games.mk2.arena.MortalKombat2ArenaModule;
  17. import org.jfge.games.mk2.effect.MortalKombat2EffectModule;
  18. import org.jfge.games.mk2.fighter.MortalKombat2FighterModule;
  19. import org.jfge.games.mk2.game.MortalKombat2GameModule;
  20. import org.jfge.games.mk2.projectile.MortalKombat2ProjectileModule;
  21. import org.jfge.games.mk2.render.MortalKombat2RenderModule;
  22. import org.jfge.games.sf2.arena.StreetFighter2ArenaModule;
  23. import org.jfge.games.sf2.collision.StreetFighter2CollisionModule;
  24. import org.jfge.games.sf2.fighter.StreetFighter2FighterModule;
  25. import org.jfge.games.sf2.game.StreetFighter2GameModule;
  26. import org.jfge.games.sf2.projectile.StreetFighter2ProjectileModule;
  27. import org.jfge.games.sf2.renderer.StreetFighter2RenderModule;
  28. import org.jfge.games.sfvsmk2.arena.SfVsMk2ArenaModule;
  29. import org.jfge.games.sfvsmk2.collision.SfVsMk2CollisionModule;
  30. import org.jfge.games.sfvsmk2.game.SfVsMk2GameModule;
  31. import org.jfge.spi.controller.Controller;
  32. import android.app.Activity;
  33. import android.content.pm.ActivityInfo;
  34. import android.content.res.Configuration;
  35. import android.os.Bundle;
  36. import android.view.KeyEvent;
  37. import android.view.Window;
  38. import com.google.inject.Guice;
  39. import com.google.inject.Injector;
  40. import com.google.inject.Key;
  41. import com.google.inject.TypeLiteral;
  42. import com.google.inject.name.Names;
  43. /**
  44. * The Class SfVsMk2.
  45. */
  46. public class SfVsMk2 extends Activity{
  47. /** The injector. */
  48. private Injector injector;
  49. /** The controller. */
  50. private Controller controller;
  51. /** The game. */
  52. private Game game;
  53. /**
  54. * Instantiates a new sf vs mk2.
  55. */
  56. public SfVsMk2() {
  57. injector = Guice.createInjector(
  58. new EngineModule(),
  59. new AndroidGraphicsModule(this),
  60. new CollisionModule(),
  61. new EffectModule(),
  62. new PhysicsModule(),
  63. new FighterModule(),
  64. new SceneModule(),
  65. new AiModule(),
  66. new ProjectileModule(),
  67. new ArenaModule(),
  68. new RenderModule(),
  69. new GameModule(),
  70. // street fighter modules
  71. new StreetFighter2FighterModule(),
  72. new StreetFighter2ArenaModule(),
  73. new StreetFighter2RenderModule(),
  74. new StreetFighter2ProjectileModule(),
  75. new StreetFighter2CollisionModule(),
  76. new StreetFighter2GameModule()
  77. // mortal kombat modules
  78. // new MortalKombat2ArenaModule(),
  79. // new MortalKombat2FighterModule(),
  80. // new MortalKombat2EffectModule(),
  81. // new MortalKombat2ProjectileModule(),
  82. // new MortalKombat2RenderModule(),
  83. // new MortalKombat2GameModule(),
  84. // street fighter vs. mortal kombat 2 modules
  85. // new SfVsMk2ArenaModule(),
  86. // new SfVsMk2GameModule(),
  87. // new SfVsMk2CollisionModule()
  88. );
  89. }
  90. // @Override
  91. // public boolean onCreateOptionsMenu(Menu menu) {
  92. // super.onCreateOptionsMenu(menu);
  93. // menu.add(0, MENU_EXIT, 0, R.string.menu_exit);
  94. // return true;
  95. // }
  96. // public boolean onOptionsItemSelected(MenuItem item) {
  97. // System.exit(0);
  98. // return true;
  99. // }
  100. @Override
  101. public boolean onKeyDown(int keyCode, KeyEvent event) {
  102. return ((android.view.KeyEvent.Callback) controller).onKeyDown(keyCode, event);
  103. }
  104. @Override
  105. public boolean onKeyUp(int keyCode, KeyEvent event) {
  106. return ((android.view.KeyEvent.Callback) controller).onKeyUp(keyCode, event);
  107. }
  108. /* (non-Javadoc)
  109. * @see android.app.Activity#onCreate(android.os.Bundle)
  110. */
  111. @Override
  112. protected void onCreate(Bundle savedInstanceState) {
  113. super.onCreate(savedInstanceState);
  114. requestWindowFeature(Window.FEATURE_NO_TITLE);
  115. Map<String, Game> games = injector.getInstance(Key.get(new TypeLiteral<Map<String, Game>>() {}));
  116. this.controller = injector.getInstance(Key.get(Controller.class, Names.named("keyboard.android")));
  117. this.game = games.get("streetFighter2");
  118. game.start();
  119. }
  120. /* (non-Javadoc)
  121. * @see android.app.Activity#onConfigurationChanged(android.content.res.Configuration)
  122. */
  123. @Override
  124. public void onConfigurationChanged(Configuration newConfig) {
  125. super.onConfigurationChanged(newConfig);
  126. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  127. }
  128. }