/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here //base initialize calls loadcontent base.Initialize(); random = new Random(); playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); spritePlayer = new Sprite3(true, playerTex, 50, SCREEN_HEIGHT / 2 - 50); spritePlayer.setWidthHeight(100, 100); spritePlayer.setFlip(SpriteEffects.FlipHorizontally); //spritePlayer.setBB(0,0,200, 200); scrollBack = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -1 + playerSpeeeeeed, 2); scrollFore = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -2 + playerSpeeeeeed, 2); textScore = new TextRenderable("Score : " + score.ToString(), new Vector2(100, 100), spriteFont, Color.Red); textStartGame = new TextRenderable("PRESS ENTER TO START", new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2), spriteFont, Color.Red); particleList = new SpriteList(); enemyList = new SpriteList(); playerBulletList = new SpriteList(); }
public override void Draw(GameTime gameTime) { graphicsDevice.Clear(Color.DeepSkyBlue); // TODO: Add your drawing code here spriteBatch.Begin(); scrollBack.colour = Color.Aqua; scrollBack.Draw(spriteBatch); scrollFore.Draw(spriteBatch); particleList.Draw(spriteBatch); player.Draw(spriteBatch); enemyList.Draw(spriteBatch); playerBulletList.Draw(spriteBatch); textScore.Draw(spriteBatch); //display bounding boxes if (Game1.showbb) { player.drawBB(spriteBatch, Color.Red); LineBatch.drawLineRectangle(spriteBatch, player.playArea, Color.Purple); enemyList.drawInfo(spriteBatch, Color.Red, Color.Blue); playerBulletList.drawInfo(spriteBatch, Color.Red, Color.Blue); } switch (levelState) { case LEVELSTATE.LEVELSTART: textVarious = new TextRenderable("LEVEL: " + level.ToString(), new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); textVarious.Draw(spriteBatch); textVarious = new TextRenderable("Enemies: " + enemyToSpawn.ToString(), new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2 + 30), spriteFont, Color.Red); textVarious.Draw(spriteBatch); break; case LEVELSTATE.LEVELGAMEOVER: textVarious = new TextRenderable("GAME OVER", new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); textVarious.Draw(spriteBatch); textVarious = new TextRenderable("Press Q to go to menu.", new Vector2(Game1.SCREEN_WIDTH / 2, (Game1.SCREEN_HEIGHT / 2) + 30), spriteFont, Color.Red); textVarious.Draw(spriteBatch); break; case LEVELSTATE.LEVELFINISH: textVarious = new TextRenderable("LEVEL FINISHED", new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); textVarious.Draw(spriteBatch); textVarious = new TextRenderable("Press Enter to go to Next Level.", new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2 + 30), spriteFont, Color.Red); textVarious.Draw(spriteBatch); break; } textLevel.Draw(spriteBatch); spriteBatch.End(); }
public override void LoadContent() { base.LoadContent(); spriteFont = Content.Load <SpriteFont>("file"); texBackground = Content.Load <Texture2D>("background"); texForeground = Content.Load <Texture2D>("foreground"); textPause = new TextRenderable("PAUSE - Press P to unpause", new Vector2(Game1.SCREEN_WIDTH / 2 - 100, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); }
public override void EnterLevel(int fromLevelNum) { base.EnterLevel(fromLevelNum); Console.WriteLine("BEGINNING "); if (gameStateManager.getLevel(fromLevelNum) is GameLevel1) { GameLevel1 lastGameLevel = gameStateManager.getLevel(fromLevelNum) as GameLevel1; level = lastGameLevel.level + 1; Console.WriteLine("LEVEL: " + level.ToString()); score = lastGameLevel.score; enemyToSpawn = lastGameLevel.enemyToSpawn + 3; } else { level = 1; score = 0; enemyToSpawn = 10; } enemyCounter = 0; //initialize level texts textLevel = new TextRenderable("LEVEL: " + level.ToString(), new Vector2(20, 20), spriteFont, Color.Red); textScore.text = "Score : " + score.ToString(); //initialize player for new level player = new Player(true, playerTex, 50, Game1.SCREEN_HEIGHT / 2 - 50); player.setWidthHeight(100, 100); player.setFlip(SpriteEffects.FlipHorizontally); //initalize level state levelState = LEVELSTATE.LEVELSTART; //initialize lists particleList = new SpriteList(); enemyList = new SpriteList(); playerBulletList = new SpriteList(); Console.WriteLine("enemyCounter" + enemyCounter); Console.WriteLine("enemyToSpawn" + enemyToSpawn); scrollBack = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -1 + player.playerBackgroundSpeed, 2); scrollFore = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -2 + player.playerBackgroundSpeed, 2); //initialize eneemy player targetting. EnemyEasy.player = player; }
public override void Draw(GameTime gameTime) { graphicsDevice.Clear(Color.LightCoral); //implements a camera spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, cam.get_transformation(graphicsDevice)); //background here platformList.Draw(spriteBatch); enemyList.Draw(spriteBatch); sliceList.Draw(spriteBatch); particleList.Draw(spriteBatch); player.Draw(spriteBatch); if (showbb) { //enemyList.drawInfo(spriteBatch, Color.Red, Color.Yellow); sliceList.drawInfo(spriteBatch, Color.Red, Color.Yellow); player.drawBB(spriteBatch, Color.Red); platformList.drawInfo(spriteBatch, Color.Red, Color.Yellow); LineBatch.drawLineRectangle(spriteBatch, new Rectangle((int)PlayerSpawnPosition.X, (int)PlayerSpawnPosition.Y, 20, 20), Color.Black); LineBatch.drawLineRectangle(spriteBatch, OutOfBounds, Color.Red); } goal.Draw(spriteBatch); spriteBatch.End(); //DRAW UI STUFF HERE spriteBatch.Begin(); abilityIconDoubleJump.Draw(spriteBatch); abilityIconDash.Draw(spriteBatch); abilityIconSlice.Draw(spriteBatch); TextRenderable score = new TextRenderable("SCORE: " + Game1.TimeScore.ToString(), new Vector2(100, 100), MenuScreen.menuFont, Color.Black); score.Draw(spriteBatch); //spriteBatch.Draw(texMouseCursor, new Vector2(InputManager.Instance.GetMousePositionX(), InputManager.Instance.GetMousePositionY()), Color.White); spriteBatch.Draw(texMouseCursor, null, new Rectangle(InputManager.Instance.GetMousePositionX(), InputManager.Instance.GetMousePositionY(), 30, 30), null, null, 0, null, Color.White, SpriteEffects.FlipHorizontally, 0); spriteBatch.End(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here levelManager.getCurrentLevel().Draw(gameTime); if (toggleHelp) { spriteBatch.Begin(); TextRenderable helpStuff = new TextRenderable("GAMEPAD: A to jump/select. B to dash. RB to slice.", new Vector2(100, 100), MenuScreen.menuFont, Color.Black); helpStuff.Draw(spriteBatch); helpStuff = new TextRenderable("KEYBOARD: Z to jump/select. C to dash. X to slice. ARROWS to move", new Vector2(100, 150), MenuScreen.menuFont, Color.Black); helpStuff.Draw(spriteBatch); spriteBatch.End(); } base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { spriteBatch.Begin(); spriteBatch.Draw(texBackground, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), Color.White); spriteBatch.Draw(texForeground, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), Color.White); if ((int)timer % 2 == 0) { textEnter = new TextRenderable("PRESS ENTER TO START", new Vector2(Game1.SCREEN_WIDTH / 2 - 100, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); textEnter.Draw(spriteBatch); textEnter = new TextRenderable("PRESS ESCAPE TO QUIT", new Vector2(Game1.SCREEN_WIDTH / 2 - 100, Game1.SCREEN_HEIGHT / 2 + 40), spriteFont, Color.Red); textEnter.Draw(spriteBatch); } spriteBatch.End(); }
public override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. texBackground = Content.Load <Texture2D>("background"); texForeground = Content.Load <Texture2D>("foreground"); spriteFont = Content.Load <SpriteFont>("file"); playerTex = Content.Load <Texture2D>("SShip4m"); explosionTex = Content.Load <Texture2D>("Boom3"); enemyTex = Content.Load <Texture2D>("Black1M"); bulletTex = Content.Load <Texture2D>("purple32x32d"); random = new Random(); //spritePlayer.setBB(0,0,200, 200); textScore = new TextRenderable("Score : " + score.ToString(), new Vector2(100, 100), spriteFont, Color.Red); textStartGame = new TextRenderable("PRESS ENTER TO START. P TO PAUSE", new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2), spriteFont, Color.Red); //SOUNDS soundBullet = Content.Load <SoundEffect>("mt2sounds/laser"); soundBulletLimit = new LimitSound(soundBullet, 3); soundEnemyHit = Content.Load <SoundEffect>("mt2sounds/hit"); soundEnemyHitLimit = new LimitSound(soundEnemyHit, 3); soundExplosion = Content.Load <SoundEffect>("mt2sounds/explosion"); soundExplosionLimit = new LimitSound(soundExplosion, 3); }
public override void Draw(GameTime gameTime) { Vector2 middleScreen = new Vector2(Game1.SCREEN_WIDTH / 2, Game1.SCREEN_HEIGHT / 2); spriteBatch.Begin(); textRenderable = new TextRenderable(titleString, middleScreen + new Vector2(0, -100), titleFont, Color.White); textRenderable.Draw(spriteBatch); for (int i = 0; i < menuStrings.Count; i++) { textRenderable = new TextRenderable(menuStrings[i], middleScreen + new Vector2(0, i * 50), menuFont, Color.White); textRenderable.Draw(spriteBatch); } textRenderable = new TextRenderable("HIGHSCORES", middleScreen + new Vector2(-300, -50), menuFont, Color.White); textRenderable.Draw(spriteBatch); for (int i = 0; i < 5; i++) { textRenderable = new TextRenderable((i + 1).ToString() + ". " + Game1.Scores[i].ToString(), middleScreen + new Vector2(-300, i * 50), menuFont, Color.White); textRenderable.Draw(spriteBatch); } if (unlockChallengeMode == true) { textRenderable = new TextRenderable("CHALLENGE HIGHSCORES", middleScreen + new Vector2(300, -50), menuFont, Color.Red); textRenderable.Draw(spriteBatch); for (int i = 0; i < 5; i++) { textRenderable = new TextRenderable((i + 1).ToString() + ". " + Game1.ChallengeScores[i].ToString(), middleScreen + new Vector2(300, i * 50), menuFont, Color.Red); textRenderable.Draw(spriteBatch); } } selector.Position = middleScreen + new Vector2(200, menuSelector * 50 - selector.getWidth() / 2); selector.Draw(spriteBatch); particleList.Draw(spriteBatch); sliceList.Draw(spriteBatch); spriteBatch.End(); }
void IRenderAboveWorld.RenderAboveWorld(Actor self, WorldRenderer wr) { if (!Enabled) { return; } foreach (var uv in wr.Viewport.VisibleCellsInsideBounds.CandidateMapCoords) { var cell = uv.ToCPos(wr.World.Map); var center = wr.World.Map.CenterOfCell(cell); var terrainType = self.World.Map.CustomTerrain[cell]; if (terrainType == byte.MaxValue) { continue; } var info = wr.World.Map.GetTerrainInfo(cell); var render = new TextRenderable(font, center, 0, info.Color, info.Type); render.Render(wr); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); LineBatch.init(GraphicsDevice); // load all fonts for the splash screen and levels llFont = Content.Load <SpriteFont>("Large"); mmFont = Content.Load <SpriteFont>("Medium"); ssFont = Content.Load <SpriteFont>("Small"); // load textures from local content directory kcTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/kittyCat.png"; kittyCatTex = Util.texFromFile(GraphicsDevice, kcTexPath); bbTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/Background.png"; backgroundTex = Util.texFromFile(GraphicsDevice, bbTexPath); playerTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/KittyCatFrames.png"; playerTex = Util.texFromFile(GraphicsDevice, playerTexPath); doggyTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/CrazyDogFrames.png"; doggyTex = Util.texFromFile(GraphicsDevice, doggyTexPath); yarnTex = Content.Load <Texture2D>("Yarn"); // position vector for the cat sprite on main splash screen kittyCatVec = new Vector2(275, 50); titleVec = new Vector2(100, 300); sloganVec = new Vector2(290, 400); instructVec = new Vector2(315, 425); levelIntroVec = new Vector2(250, 200); playerVec = new Vector2(600, 400); doggyVec = new Vector2(0, 400); // make the cat sprite for the main splash screen kittyCat = new Sprite3(true, kittyCatTex, kittyCatVec.X, kittyCatVec.Y); // prepare the crazy dog for level 2 crazyDog = new Sprite3(false, doggyTex, doggyVec.X, doggyVec.Y); // color for the level text and alpha value ltCol = new Color(0, 255, 0, 1); // level text initialization levelText = new TextRenderable("Blabla", levelIntroVec, llFont, Color.Red); // source and destination rectangles for the scrolling background backgroundDest = new Rectangle(0, 0, 800, 600); backgroundSource = new Rectangle(0, 0, 800, 600); // draw background background = new ScrollBackGround(backgroundTex, backgroundDest, backgroundSource, 5.0f, 2); // player vector and player texture playerSprite = new Sprite3(true, playerTex, playerVec.X, playerVec.Y); // initialize frame vector playerFrames = new Vector2[10]; // frame vector values 1280x128 playerFrames[0].X = 0; playerFrames[0].Y = 0; playerFrames[1].X = 1; playerFrames[1].Y = 0; playerFrames[2].X = 2; playerFrames[2].Y = 0; playerFrames[3].X = 3; playerFrames[3].Y = 0; playerFrames[4].X = 4; playerFrames[4].Y = 0; playerFrames[5].X = 5; playerFrames[5].Y = 0; playerFrames[6].X = 6; playerFrames[6].Y = 0; playerFrames[7].X = 7; playerFrames[7].Y = 0; playerFrames[8].X = 8; playerFrames[8].Y = 0; playerFrames[9].X = 9; playerFrames[9].Y = 0; // set all the parameters for the cute little kitty cat playerSprite.setWidthHeight(64, 64); playerSprite.setWidthHeightOfTex(1280, 128); playerSprite.setXframes(10); playerSprite.setYframes(0); playerSprite.setBB(0, 0, 128, 128); playerSprite.setAnimationSequence(playerFrames, 0, 9, 15); playerSprite.animationStart(); // the parameters for the player sprite jumping playerJump = false; playerJumpSpeed = 0; // store the initial positions of the player sprite prevPos.Y = playerVec.Y; prevPos.X = playerVec.X; // initialize sounds for the game jumpo = Content.Load <SoundEffect>("Sounds/Boing"); jumpoSound = new LimitSound(jumpo, 1); success = Content.Load <SoundEffect>("Sounds/Success"); successSound = new LimitSound(success, 1); barko = Content.Load <SoundEffect>("Sounds/Growl"); barkoSound = new LimitSound(barko, 1); kaching = Content.Load <SoundEffect>("Sounds/Kaching"); kachingSound = new LimitSound(kaching, 1); yowlin = Content.Load <SoundEffect>("Sounds/Yowl"); yowlinSound = new LimitSound(yowlin, 1); easterEgg = Content.Load <SoundEffect>("Sounds/OhWhatever"); eeSound = new LimitSound(easterEgg, 1); /// yarn ball sprite list /// /// /// /// /// /// yarnBalls = new SpriteList(); Sprite3 yb; for (int i = 0; i < maxYarnBalls; i++) { // temporarily set to doggyVec for positioning - change later? yb = new Sprite3(true, yarnTex, doggyVec.X + i * 50, doggyVec.Y - i * 50); yb.setDeltaSpeed(new Vector2((float)(1 + rnd.NextDouble()), 0)); yb.setWidthHeight(32, 32); yb.setWidthHeightOfTex(32, 32); yb.setHSoffset(new Vector2(32, 32)); yb.setBBToTexture(); yb.setMoveSpeed(2.1f); yarnBalls.addSpriteReuse(yb); } // initialize frame vector for dog doggyFrames = new Vector2[8]; doggyFrames[0].X = 0; doggyFrames[0].Y = 0; doggyFrames[1].X = 1; doggyFrames[1].Y = 0; doggyFrames[2].X = 2; doggyFrames[2].Y = 0; doggyFrames[3].X = 3; doggyFrames[3].Y = 0; doggyFrames[4].X = 4; doggyFrames[4].Y = 0; doggyFrames[5].X = 5; doggyFrames[5].Y = 0; doggyFrames[6].X = 6; doggyFrames[6].Y = 0; doggyFrames[7].X = 7; doggyFrames[7].Y = 0; crazyDog.setWidthHeight(64, 64); crazyDog.setWidthHeightOfTex(1024, 128); crazyDog.setXframes(8); crazyDog.setYframes(0); crazyDog.setBB(0, 0, 128, 128); crazyDog.setAnimationSequence(playerFrames, 0, 7, 15); crazyDog.animationStart(); }
/// <summary> /// Click to confirm position of the free point. If more fields, call to /// load next field. If no more, render the path map. Then close. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OK_Click(object sender, EventArgs e) { if (complete) { this.Hide(); return; } f.DefineFreePoint(point); PRMs.Add(new PRMAlgorithm(f, 0.35, (int)(f.AreaDifference() / 0.2))); if (++count <= fields.Count) { f = fields[count - 1]; LoadNext(); } else //if all points found render all lines { reset(); Number_Label.Text = "Path Map and PRM"; OK.Text = "Save"; Vector2 center = new Vector2(0, 0); List<Polygon> fieldsComp = new List<Polygon>(); List<Polygon> wallsComp = new List<Polygon>(); List<Polygon> objectsComp = new List<Polygon>(); List<Polygon> regionsComp = new List<Polygon>(); foreach (Field ff in fields) { fieldsComp.Add(ff.shape); TextRenderable name = new TextRenderable(ff.name, new PointF((float)ff.shape.Center.X, (float)ff.shape.Center.Y), Color.Black); rend.AddRenderable(name); center += ff.shape.Center; foreach (List<Polygon> p in ff.walls.Values) { wallsComp.AddRange(p); } foreach (List<Polygon> p in ff.objects.Values) { objectsComp.AddRange(p); } foreach (List<Polygon> p in ff.regions.Values) { regionsComp.AddRange(p); } } fieldsRend.Polygons = fieldsComp; wallsRend.Polygons = wallsComp; objectsRend.Polygons = objectsComp; regionsRend.Polygons = regionsComp; center /= fields.Count; rend.CamOrtho.CameraPosition = new PoseYPR(center.X, center.Y, rend.CamOrtho.CameraPosition.z, rend.CamOrtho.CameraPosition.yaw, rend.CamOrtho.CameraPosition.pitch, rend.CamOrtho.CameraPosition.roll); OK.Enabled = true; complete = true; pm = new PRMNavigationPlanner(PRMs, "").getPathMap(); foreach (PRMAlgorithm prm in PRMs) { foreach (Vector2 v in prm.getNodeVector2()) { PointRenderable pointr = new PointRenderable(v); rend.AddRenderable(pointr); } } foreach (PathMapNode pmn in pm.map) { PathRenderable line = new PathRenderable(new List<Vector2>() { pmn.v1.Item1, pmn.v2.Item1 }); line.DisplayColor = Color.Blue; lines.Add(line); rend.AddRenderable(line); } } }