1 / 67

Video Game Programming Level One – Platformer

Video Game Programming Level One – Platformer. INSTRUCTOR: <Your Name Here>. PART 1 –Platformer Basics. Objective: Unpack the platform engine and perform a test build. Step 1 – Platformer Setup Step 2 – Save and Test. CONCEPT – Third Party Game Engines.

eadoin
Download Presentation

Video Game Programming Level One – Platformer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Video Game ProgrammingLevel One – Platformer INSTRUCTOR: <Your Name Here>

  2. PART 1 –Platformer Basics Objective: Unpack the platform engine and perform a test build. • Step 1 – Platformer Setup • Step 2 – Save and Test

  3. CONCEPT – Third Party Game Engines • Some game developers create their games using in house game engines, which are simply a framework and series of tools from which you can create a game. For instance, the ProjectFUN Editor is a game engine. • They also put these pieces of software on the market for other developers to use.

  4. CONCEPT – Third Party Game Engines Continued ... • In this project, you will be getting the Platformer Engine, which is something written in the ProjectFUN Editor to ease the creation of platformer-style games. • The Platformer Engine has all the base code that you need to create a simple platforming game.

  5. STEP 1: Platformer Setup • Open Platform Engine.fun • Change the window title to Platformer (Your Name) • Save the project as Platformer_(Your Name).fun.

  6. STEP 2: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • The project should build without any errors.

  7. PART 2 – Initial Asset Setup Objective: Import the actors and animation sets using the Import Wizard. Look at some options to optimize the animations. • Step 1 – The Import Wizard • Step 2 – Reviewing Engine Data • Step 3 – Save and Test

  8. STEP 1: The Import Wizard • The Import Wizard is located in the Resources menu. • Open the Import Wizard and use it to import the PLYR Actor from platformer11.fun.

  9. CONCEPT – Horizontal Flipping • Consider the situation where you want a character to walk both left and right; normally you would need to make two separate animations for this. • The ProjectFUN Editor automates this process with Horizontal Flipping. H-Flip flips the animation when the movement direction changes signs (e.g. From positive to negative). • NOTE: H-Flip assumes that the character is initially right-facing.

  10. STEP 2: Reviewing Engine Data • There is already code and some Local Data entered into the Platformer Engine. • Take a look at the following code: • PlyrOnWhatSM: Determines if the owning Sprite is on a platform or in the air, and reacts accordingly. • My Functions: These are some useful pre-written functions that ease the creation of your game, as well as providing detailed error messages when something goes wrong.

  11. STEP 2: Reviewing Engine DataCONTINUED • GravityFactor is a global value used for gravity. • PlayerLD is Local data to store values such as the player’s jumping power and speed.

  12. STEP 3: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • The project should build without any errors.

  13. PART 3 – Levels Objective: Add the levels to be in the game. • Step 1 – Add the levels • Step 2 – Bypass to Level_1 • Step 3 – Level_1’s Map • Step 4 – Save and Test

  14. CONCEPT – Adding Levels • Sometimes it is good to add all of the levels that are fundamentally different at the same time. • When levels are added later, a copy of another level can be made so information doesn’t need to be set up repeatedly.

  15. STEP 1: Add the Levels • Add a level called TitleScreen. • Add a level called MainMenu. • Add a level called Level_1.

  16. STEP 2: Bypass to Level_1 • When you’re creating a game that has a lot of levels, it is hard to debug a problem on Level 20, say, when you have to keep playing through Levels 1-19 over and over. • It’s a good idea to put in a “bypass” to Level 20, so you can go straight to the problem. • That’s exactly what we’re doing here.

  17. STEP 2: Bypass to Level_1 Continued... • Add the following code to the game’s OnStart to skip to Level_1: myGame->LevelName(“Level_1”);

  18. STEP 3: Level_1’s Map • Add a map to Level_1. • The collision data for the platforms should be added to this map. • Each platform will need collision data pointing up on the top. • The map should have collision data added around the edges to keep the player in the world; the left and right sides of the map should have a Collision ID of 1

  19. STEP 4: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • When the game is run Level_1 should come up with the platforms map in the background.

  20. PART 4 – The Player Objective: Put the player into the game. • Step 1 – Add the Player Sprite • Step 2 – Save and Test

  21. CONCEPT – State Machines • In different game projects, a need arises for controlled collections of different behaviour. • Each “state” represents a different type of behaviour, such as an AI-controlled guard might patrol or chase away the player. Each behaviour, patrolling and chasing, is a different state. • Between two States is an “edge”, which essentially controls if the current behaviour changes to a different state. For instance, if the guard sees the player, he will change from patrolling to chasing. This change, is represented as an Edge. • In the ProjectFUN Editor, these States and Edges comprise what is known as a State Machine.

  22. CONCEPT – State Machines Continued... • Each State Machine has a “Starting State”, which is the default behaviour to start in. An example with our guard would be that he starts out in the game patrolling, and then can change states from there. • Additionally, every State Machine has a “Current State”, which is the currently active behaviour. This could be patrolling or chasing, respectively. • Finally, each State has both an OnStart behaviour and an Update behaviour. The OnStart is called when the State is first activated (such as when changing states) and the Update is called every frame while the State is active.

  23. STEP 1: Add the Player Sprite • Add the sprite “Player” to Level_1 • Give the player sprite the PlyrOnWhatSM state machine. • Give the player sprite the PlayerLD local data object and set its Display List to 1. • Set the player’s collision to precise and check collision with sprites and the map.

  24. STEP 2: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • When the game is run the player should be able to jump around the screen.

  25. PART 5 – The Key Objective: Put the Key pickup into the game. • Step 1 – Import the Key Actor • Step 2 – Add the Key Sprite • Step 3 – Update the PlayerLD • Step 4 – PlayerUpdateFN • Step 5 – Save and Test

  26. CONCEPT – Pickups in Games • In many games there is the need to add a puzzle element to the gameplay, which can be represented as a “pickup”. • Pickups in games represent a goal that the player must achieve, while fulfilling the puzzle requirements. An example of pickups would be the colored keys in DOOM or the golden rings in Sonic. • In the Platformer, the Key represents the goal that the player must achieve to open the door to the next level. Ideally, it will be difficult to get, but not too difficult.

  27. STEP 1: Import the Key Actor • Open the Import Wizard and import the KEY actor from platformer11.fun.

  28. STEP 2: Add the Key Sprite • Create a new sprite and name it Key. • Set the Key to only check collision with other sprites. • Set the Actor for the Key

  29. STEP 3: Update the PlayerLD • Open the PlayerLD local data and add a boolean variable named HaveKey. • This value will be used to keep track of whether or not the player holds the key, so set the initial value to false.

  30. STEP 4: PlayerUpdateFN Use: This function will detect when the player picks up the key and will change the HaveKey flag in PlayerLD. • Create an Object Function named PlayerUpdateFN and enter the following code for the function body. • Then add this behavior to the Player sprite

  31. PlayerUpdateFN Code • Sprite* key = This->CollisionWithSpritePtr( "Key" ); • if ( key ) • { • PlayerLD *PlayerData = GetPlayerLD( This ); • PlayerData->HaveKey = true; • key->DeleteFlag( true ); • }

  32. STEP 5: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • When the game is run the player should be able to pick up the key.

  33. PART 6 – The Gate Objective: Put the Gate into the game. • Step 1 – Import the Gate Actor • Step 2 – Add the Gate Sprite • Step 3 – Modify the PlayerUpdateFN • Step 4 – Save and Test

  34. CONCEPT – Sprites as Map Objects • Another necessity in many games are pieces of the level that react to player input, such as a pressure pad to a door or mine in the sand. • In the ProjectFUN Editor, you can accomplish this by letting Sprites masquerade as parts of the level. • For instance, in the Platformer, the Gate has specific behaviour if it is opened, but it does not move. It acts as a door to the next level, and not as a separate moving entity. This is precisely the concept that we’re trying to get at. The Gate Sprite acts as if it were a piece of the level, and not necessarily a Sprite.

  35. STEP 1: Import the Gate Actor • Open the Import Wizard and import the GATE actor from platformer11.fun.

  36. STEP 2: Add the Gate Sprite • Create a new sprite and name it Gate. • Set the Gate to only check collision with other sprites. • Set the Actor for the Gate

  37. STEP 3: Modify PlayerUpdateFN • Update PlayerUpdateFN with the following bold face code changes.

  38. STEP 3: Modify PlayerUpdateFN • Sprite* key = This->CollisionWithSpritePtr( "Key" ); • if ( key ) • { • PlayerLD *PlayerData = GetPlayerLD( This ); • PlayerData->HaveKey = true; • key->DeleteFlag( true ); • SpritePTRpGate( "Gate" ); • pGate->Animation( GATE_OPENED); • } • if ( This->CollisionWithSprite( "Gate" ) && • GetPlayerLD( This )->HaveKey ) • myGame->NextLevel();

  39. STEP 4: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • When the player picks up the key the gate should open.

  40. PART 7 – Level 2 Objective: Create Level_2 by making a copy of Level_1. • Step 1 – Copy Level_1 • Step 2 – Modify the New Level • Step 3 – Save and Test

  41. STEP 1: Copy Level_1 • Insert a copy of Level_1 and name it Level_2.

  42. STEP 2: Modify the New Level • Create a map in an art program or use the provided level art. • Use this map for Level_2’s map • Add the collision data to the map. • Change the Key’s position. • Change the Gate’s position.

  43. STEP 3: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • Level_2 should display with the new map. Test and tweak this map to better gameplay.

  44. PART 8 – The Enemy Guard Objective: Add in a guard and reuse the code for the behavior. • Step 1 – Import the Actor • Step 2 – Add the GuardLD • Step 3 – Create EnemyOnWhatSM • Step 4 – Add the Guard Sprite • Step 5 – Save and Test

  45. STEP 1: Import the Actor • Import the ENEMY actor from platformer11.fun

  46. STEP 2: Add the GuardLD • Add Local Data GuardLD. • Add a boolean value Jumping with initial value false. • Add a float value JumpStrength with initial value 10.5. • Add an integer value delay with initial value 100.

  47. STEP 3: Create EnemyOnWhatSM • Import the EnemyOnWhateSM from the platformer11.fun.

  48. STEP 4: Add the Guard Sprite • Add an Enemy sprite. • Give it the ENEMY actor and add the GuardLD. • Use EnemyOnWhatSM for the behavior. • Position the guard on the map away from the start position of the player.

  49. STEP 5: Save and Test • Save the Project: • Click on Project and Save. • Run the Project: • Click on the Build/Run button in the menu bar. • Results: • Level_2 should display and the guard should appear in the level.

  50. PART 8 – AI for the Enemy Guard Objective: Give the guard an update function that will make the guard appear to be somewhat intelligence, such as aggressive chasing behavior. • Step 1 – EnemyUpdateFN • Step 2 – Save and Test

More Related