Key Terms:
Code
Condition
criterion
false
true
program
pseudocode
flowchart
variable
Lesson Plan: Event Coding
TEKS 7(3) Creativity and innovation--innovative design process (B) discuss and implement a design process that includes planning and selecting digital tools to develop and refine a prototype or model through trial and error;
Learning Objective
I will code events for my game
Success Criteria
I can can code events to execute my game and components.
What Sprites did you create for your game?
Computer Science Concepts
Code
Event
criterion
pseudocode
flowchart
Examples of Flow charts
Video games, even simple ones, can have a lot of moving parts and rules. Flowcharts and pseudocode help game developers by:
Breaking Down Complexity: They help you take a big idea (like "make a game") and break it into smaller, manageable steps.
Visualizing Logic: Flowcharts give you a clear picture of how different parts of your game connect and what happens under different conditions.
Finding Problems Early: By planning, you can spot potential issues or missing steps before you start coding, saving you a lot of time and frustration.
Communicating Ideas: They make it easier to explain your game's logic to others, especially if you're working in a team.
Guiding Your Code: Once you have a good flowchart and pseudocode, translating it into actual programming code becomes much simpler!
Imagine you're giving instructions to a robot. A flowchart is like a visual map of those instructions. It uses different shapes to represent different types of steps in a process, and arrows to show the order of those steps.
If a flowchart is a visual map, then pseudocode is like a detailed outline written in plain English (or whatever language you speak!). It describes the steps of a program or algorithm using a structured format, but without worrying about the exact syntax of a specific programming language.
Key Characteristics of Pseudocode:
Plain Language: Uses words you understand, not complex code.
Structured: Uses indentation and keywords (like IF, THEN, ELSE, WHILE, FOR) to show logic, similar to how code is structured.
Not Executable: You can't run pseudocode on a computer; it's just for planning.
Lesson Plan: Sprite Coding
TEKS 7(3) Creativity and innovation--innovative design process (B) discuss and implement a design process that includes planning and selecting digital tools to develop and refine a prototype or model through trialÂ
Learning Objective   Â
I will code my characters and sprites and objects
Success Criteria
I can code my sprites and characters for my game.
Computer Science Concepts
Boolean Expressions
True/False Values
Conditionals Statements
You've learned how to plan your game using flowcharts and pseudocode. Now, let's talk about the visual stars of your game: sprites! Sprites are what you see moving around on the screen – your characters, enemies, coins, power-ups, and everything else that isn't the background. In this lesson, we'll explore what sprites are and how we can bring them to life through code.
In video games, a sprite is a two-dimensional (2D) image or animation that represents an object or character. Think of them as digital cutouts that move around on your screen.
Characters: Your hero, villains, non-player characters (NPCs).
Objects: Coins, power-ups, obstacles, items.
Effects: Explosions, sparks, magical spells.
Sprites are usually designed as small images. When you play a game, the computer quickly draws and redraws these images in different positions to make them appear to move.
Imagine your game screen as a big canvas. When you code a game, you tell the computer:
Where to draw the sprite: Using X and Y coordinates (like on a graph). X tells you how far left or right, and Y tells you how far up or down.
Which sprite to draw: If you have multiple characters or different states for a character (e.g., standing, jumping).
How to change its position: This is how movement happens. You update the X or Y coordinates over time.
For example, to move a character to the right, you would repeatedly increase its X coordinate by a small amount.
A single image for a sprite is good for a static object, but characters need to move, walk, jump, or attack! This is where sprite animation comes in.
The most common way to animate sprites is using a sprite sheet (also called a sprite atlas). A sprite sheet is a single image file that contains multiple frames (different poses or stages) of an animation.
How it works:
You have a sprite sheet with all the frames for a character's walk cycle.
Your game code displays only a small rectangular portion of that sprite sheet at a time.
To animate, the code rapidly switches which portion of the sprite sheet it's displaying, creating the illusion of movement. It's like a flipbook!
Example: A Simple Walk Cycle
Imagine these are frames on a single sprite sheet:
[Frame 1: Left Foot Forward] [Frame 2: Both Feet Together] [Frame 3: Right Foot Forward] [Frame 4: Both Feet Together]
To make the character walk, the game would show Frame 1, then Frame 2, then Frame 3, then Frame 4, and then loop back to Frame 1, all very quickly.
Lesson Plan: Action Coding
TEKS (5) Data literacy, management, and representation--collect data. (A) compare and contrast data types, including binary, integers, real numbers, Boolean data, and text-based representations;
Learning Objective
I will code actions such as scoring, scene changes and movements
Success Criteria
I can code the actions of my game.
I can code movement of my game
I can code scoring components within my game.
Computer Science Concepts
Loops, Variables
Game Design Concepts
You've learned how to plan your game with flowcharts and pseudocode, and how to create the visual elements with sprites. Now, let's make your game do something! In this lesson, we'll dive into how we code actions within a video game, making characters move, collect items, and react to what's happening.
In any video game, actions are the things that happen based on player input, game rules, or interactions between game elements. They are the "verbs" of your game!
Think about your favorite games:
Movement: Your character walks, runs, jumps, flies.
Interaction: Picking up items, opening doors, talking to NPCs.
Combat: Attacking enemies, using spells, taking damage.
Collecting: Picking up coins, power-ups, resources.
Game State Changes: A timer counting down, a score increasing, a level ending.
All these actions are powered by code that tells the computer what to do and when.
Games are constantly waiting for something to happen. This "something" is often called an event.
Player Input Events: When you press a key on the keyboard, click the mouse, or tap the screen, these are events that your game can detect.
Game Events: These can be things like two sprites touching (a collision), a timer reaching zero, or an enemy appearing.
When an event happens, your game's code "listens" for it and then performs a specific action in response. This is called event-driven programming.
Example:
Event: Player presses the "Right Arrow" key.
Action: Move the player character to the right.
Not all actions happen all the time. Sometimes, an action only happens if a certain condition is true. This is where conditional logic comes in, using IF and ELSE statements.
IF (condition is true) THEN (do this action)
ELSE (if the condition is false) THEN (do this other action)
Many actions in a game need to happen over and over again. This is where loops are essential.
Game Loop: The main loop of almost every game. It runs continuously, hundreds of times per second, handling all the updates:
Check for player input.
Update positions of all sprites.
Check for collisions.
Update score, timer, health.
Draw everything on the screen.
Animation Loops: As we saw with sprites, loops are used to cycle through animation frames.
Spawning Loops: A loop might periodically create new enemies or coins.
Example (Simplified Game Loop Pseudocode):
To keep track of important information in your game, you use variables. A variable is like a named container that can hold a value, and that value can change as the game plays.
Common game variables:
score (number)
playerX, playerY (numbers for position)
playerHealth (number)
gameTimer (number)
isGameOver (true/false)
When an action happens, you often update a variable. Example:
// When a coin is collected
INCREMENT score by 10
Activity