public Wall(GameWorld gameWorld, Rectangle target) : base(gameWorld, "wall") { _target = target; Body = BodyFactory.CreateRectangle(World, ConvertUnits.ToSimUnits(_target.Width), ConvertUnits.ToSimUnits(_target.Height), 1f); Position = new Vector2(_target.X, _target.Y); SolidWall = true; }
public Enemy(GameWorld gameWorld) : base(gameWorld, "enemy") { Body = BodyFactory.CreateRectangle(World, ConvertUnits.ToSimUnits(32), ConvertUnits.ToSimUnits(32), 1f, bodyType: BodyType.Dynamic); Body.FixedRotation = true; Body.OnCollision += OnCollision; _spriteEffect = SpriteEffects.None; }
protected GameObject(GameWorld gameWorld, string textureName) { _gameWorld = gameWorld; SpriteBatch = gameWorld.SpriteBatch; Texture = gameWorld.Content.Load<Texture2D>(textureName); _world = gameWorld.World; _rectangle = new Rectangle(0, 0, Texture.Width, Texture.Width); }
public Bubble(GameWorld gameWorld) : base(gameWorld, "bubble") { Body = BodyFactory.CreateCircle(gameWorld.World, ConvertUnits.ToSimUnits(Radius), 0.1f, bodyType: BodyType.Dynamic); Body.LinearDamping = 8f; Body.Friction = 1f; Body.OnCollision += OnCollision; MaxAge = SetMaxAge(); }
public static Bubble CreateBubble(GameWorld gameWorld, Dragon dragon) { var bubbleType = Rnd.Next(0, 6); Bubble bubble; float startImpulse = 20; switch (bubbleType) { case 5: bubble = new RockBubble(gameWorld); startImpulse = 60; break; case 4: case 3: bubble = new ExplodingBubble(gameWorld); break; case 2: case 1: case 0: bubble = new Bubble(gameWorld); break; default: throw new InvalidOperationException("Bubble type: " + bubbleType); } bubble.Position = dragon.Position; if (dragon.LookDirection == LookDirection.Right) { bubble.Position += new Vector2(Dragon.Width, 0); bubble.Body.ApplyLinearImpulse(new Vector2(startImpulse, 0)); } else { bubble.Position -= new Vector2(Dragon.Width, 0); bubble.Body.ApplyLinearImpulse(new Vector2(-startImpulse, 0)); } return bubble; }
public RockBubble(GameWorld gameWorld) : base(gameWorld) { Body.Mass = 10f; Body.LinearDamping = 0; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. #if USE_TOUCH _gameInput = new TouchScreenGameInput(Content, GraphicsDevice.Viewport); #else _gameInput = new KeyboardGameInput(); #endif _spriteBatch = new SpriteBatch(GraphicsDevice); _gameWorld = new GameWorld(this); _gameWorld.Setup(); }
public ExplodingBubble(GameWorld gameWorld) : base(gameWorld) { }