Videos

[https://docs.google.com/document/d/1j3k3kffboXn2fqfQwQlN0Nni2ZYhGDbps8i7kwEUexo/edit?usp=sharing]{.underline}

Term 2 Programming concepts

  • Inputs

  • Outputs

  • Event-driven programming

  • Sequencing

  • Iteration (loops)

  • Variables

  • Data types

  • If-then-else control structures

  • Selection

  • Comparative operators

  • Functions

Week 1: Building a level and programming player controls

First steps

  • Make a new blank game

  • Grab the Wonderdot RPG pack from the Marketplace

Build only 3 rooms to get started

  • Change background colour of level to black

  • Draw walls in tilemap

  • Make new tilemap for floors, reorder layers

  • Disable collisions on floor tilemap

  • Make new tilemap for holes

  • Make new layer for props

  • Make new layer for player

  • Save game

{width="6.5in" height="3.5833333333333335in"}

Player character and controls

  • Place player character in new Player layer

  • Add new script to player

  • When right arrow pressed

  • Set velocity x 200

  • Click play to test it (save script)

  • Duplicate for all 4 directions

  • Play test

  • Duplicate 4 blocks for key release

  • Set velocities to 0

  • Play test

  • Constantly, center camera on myself

  • Play test

  • Save game

{width="6.114583333333333in" height="6.072916666666667in"}

Solid props that don't slide around

  • Add script to a prop

  • When level starts, set immovable true

  • Close script and save "immovable object"

  • Add this script to all solid immovable props

Non-solid props you can walk through

  • Add script to another object

  • When level starts, set physics enabled false

  • Close and save "non-solid object"

  • Add this script to anything non-solid

Week 2: Enemy NPCs AI and attacks

(REMINDER: Grab asset pack again to get new stuff. Remix your game to forget the pack. You can minimize the old pack to keep it out of the way)

Spikes

  • Before we add moving dangerous things (enemies), we'll add dangerous

    things that don't move (spikes)

  • Place spikes in props layer

{width="1.7083333333333333in" height="1.2708333333333333in"}

  • Add script

  • When level starts, set immovable true

  • When touched get toucher

  • If toucher has tag player (make sure player has player tag)

  • Restart current level

  • {width="5.1875in"

    height="2.7083333333333335in"}

Place NPC in new NPCs layer

  • Make new layer for NPCs

  • Place an enemy NPC somewhere near your player

{width="6.5in" height="3.763888888888889in"}

NPC AI - Charging

  • Add script to NPC

  • Constantly

  • Create a new function definition named Charge

  • Use the function call in constantly

  • Play to test (save script)

  • Charge does nothing

  • Charge: Set x velocity to 100

  • Set y velocity to 100

  • Play

  • We want velocities to be towards us so we need difference between

    position of NPC and position of player.

{width="2.9791666666666665in" height="2.7083333333333335in"}

  • Close NPC script and edit player script

  • When level starts

  • add player tag

{width="4.9375in" height="1.8229166666666667in"}

  • Open NPC script

  • Remove hardcoded numbers

  • X position of first instance by tag player - x position of myself

  • Y position player - y position myself

  • Play test

{width="6.5in" height="2.3194444444444446in"}

  • Only charge if distance to player is less than 200

  • Constantly, if

  • Distance from myself to instance other (starts as angle from)

  • Remove other, use first instance by tag player

  • Less than 200

  • Note: if you're not sure what your maths is doing or what your

    numbers are, you can log them using the log block and debug mode

{width="6.5in" height="1.7638888888888888in"}

Week 3

Adding Player Attack

  • Edit player script to add ability to attack

  • When spacebar pressed, play animation "attackDown"

  • Play game to see animation looping

  • When animation has looped, play animation "walkDown"

  • Play game to see animation stop

  • Broadcast "player attack" so NPC can receive this message

{width="4.583333333333333in" height="2.7291666666666665in"}

Adding NPC damage animation

  • Edit NPC script so it can receive message

  • When I receive "player attack"

  • Duplicate distance checker blocks (if distance from myself to player

    \< 200)

  • Create new function named "damaged"

  • In damaged function, play animation "hitDown"

  • Play test, see animation keeps looping

  • When animation "hitDown" has looped, play animation "walkDown"

  • playtest

  • After animation starts playing, set alpha to 0.5

  • In 500 ms set alpha to 1

{width="6.5in" height="4.319444444444445in"}

NPC attacking player

  • On the NPC script

  • When touched get toucher

  • If toucher has tag player

  • New function "attack"

  • In function definition: broadcast NPC attack

  • Play animation attackDown

  • When animation attackDown has looped, play animation walkDown

{width="5.15625in" height="4.03125in"}

Player health variable and textfield

  • Create number variable for Health, and textfield to display health

  • When level starts, set number health to 100

  • Create new textfield with text HP

  • Set font colour of textfield

  • Playtest

{width="4.697916666666667in" height="2.1979166666666665in"}

Snapping health textfield to camera

  • Constantly,

  • Set x position of instance textfield to camera x

  • Set y position of instance textfield to camera y

  • Playtest

{width="5.625in" height="1.7291666666666667in"}

Player receives attacks and animates

  • When I receive "NPC attack"

  • Play animation "hitDown"

  • Set alpha to 0.5

  • 500 ms, set alpha to 1

  • When hitDown has looped, play walkDown

  • Playtest

{width="4.291666666666667in" height="3.6041666666666665in"}

Player takes health damage

  • When hitDown has looped, set number health to number health - 10

  • Set text of textfield to

  • (try to drag number health in, won't work)

  • Create text with

  • Number health

  • Text block " HP"

  • Playtest

{width="6.5in" height="2.111111111111111in"}

Player death

  • If health \<= 0

  • Restart level

  • playtest

{width="4.635416666666667in" height="1.9166666666666667in"}

Week 4

NPC health variable and textfield

  • Editing NPC script

  • When level starts

  • Set number health to 50

  • Create new textfield with text "create text with" "number health" "

    HP"

  • Set font colour red

  • Set font size 26

{width="6.489583333333333in" height="2.4895833333333335in"}

NPC health text floating

  • Constantly...

  • Set x position of instance textfield to x position of myself

  • Set y position of instance textfield to y position of myself

  • Playtest

{width="6.5in" height="2.111111111111111in"}

NPC health decrease when attacked

  • In When animation hitDown has looped:

  • Set health to health - 20

  • Set text of textfield to "create text with" "number health" " HP"

  • Playtest

NPC death{width="6.5in" height="2.1527777777777777in"}

  • If health \<= 0

  • Destroy instance textfield

  • Destroy myself

  • Playtest

{width="4.21875in" height="1.9895833333333333in"}

Health potion item

  • Place a health potion in the Items layer (make new layer for it)

  • Add script

  • When level starts, set movable to false (explain difference to

    immovable)

  • When touched get toucher

  • If toucher has tag player

  • Broadcast "health potion"

  • Destroy myself

  • playtest

{width="5.21875in" height="3.0416666666666665in"}

Player receives health from potion

  • Edit player script

  • When I receive "health potion"

  • Set health to health + 10

  • Duplicate "set text..." blocks to update textfield

  • playtest

{width="6.5in" height="1.7916666666666667in"}

Add a new friendly NPC

  • Place friendly NPC on npc layer

  • Add script to friendly NPC

  • When level starts

  • Set immovable to true

  • When I am touched get toucher

  • If toucher has tag player

  • Broadcast "display chat" with "Can you save us? Kill all 5 orcs

    please!"

  • Playtest

{width="6.5in" height="2.4166666666666665in"}

Add a chat box

  • Create a new layer for Interface (menus, windows, buttons, etc that

    will appear on top of everything else)

  • Add chat box object outside of level

  • Add script to chat box object

  • When level starts, set physics enabled false, set visibility false

  • When I receive "display chat" with a value, set visibility true

  • Playtest

{width="4.114583333333333in" height="2.6354166666666665in"}

Make chat box aligned to camera

  • Constantly set x position to camera x, set y position to camera y

{width="4.3125in" height="1.4375in"}

Displaying text in chat box

  • When level starts... Create new textfield with text "This is the

    chatbox"

  • Set visibility of textfield to false

{width="5.09375in" height="1.0625in"}

  • When I receive... set visibility of textfied to true

{width="4.697916666666667in" height="0.6875in"}

  • Constantly... set x and y position of textfield to camera x and y

{width="5.5in" height="1.0104166666666667in"}

Positioning box and text at the bottom of the camera

  • Position to camera x and y as before, + these numbers

{width="6.5in" height="2.4583333333333335in"}

Using text from message value

  • When I receive... set text of textfield to

  • true/false value, change it to text

{width="5.145833333333333in" height="0.78125in"}

  • Making text nicer: When level starts...

  • set font size 24, set font colour yellow

  • set max width 900 (so it will have multiple lines if necessary)

{width="5.072916666666667in" height="1.5520833333333333in"}

Dismissing chat box with spacebar

  • When spacebar pressed

  • Set visibility false

  • Set visibility textfield false

{width="4.78125in" height="1.5104166666666667in"}

Freezing and unfreezing the player

  • When I receive... broadcast "freeze"

{width="2.7291666666666665in" height="0.8125in"}

  • When spacebar pressed...

{width="3.1458333333333335in" height="0.8020833333333334in"}

  • Then on the player script:

  • When I receive "freeze", set moves false

  • When I receive "unfreeze", set moves true

{width="2.875in" height="2.1979166666666665in"}

Week 5: Quests

Giving a quest

  • Edit Friendly NPC script

  • New variable "kill 5 orcs quest started?" set to false when level

    starts

  • add If quest started? = false to when touched

  • Set quest started to true

{width="6.5in" height="3.3194444444444446in"}

Different chat for quest stages

  • New var when level starts, set 5 orcs killed to false

  • Change if to else if

  • Else if quest active = true AND orcs killed = false,

  • broadcast display chat with

  • Create text with "Please hurry! Those last

  • 5 - number of orcs killed

  • orcs need to be dealt with"

{width="4.395833333333333in" height="0.75in"}

{width="6.5in" height="1.0694444444444444in"}

Killing enemies for the quest

  • Open NPC enemy script

  • Find destroy myself, and before that add broadcast "killed orc"

{width="3.9375in" height="1.9583333333333333in"}

  • Open NPC friendly script

  • Add when I receive "killed orc", set new number var "number of orcs

    killed" + 1

  • Check if number orcs killed = 5

  • Set "5 orcs killed?" to true

  • Set number orcs killed to 0 when level starts

{width="6.5in" height="1.7777777777777777in"}

{width="4.229166666666667in" height="0.7708333333333334in"}

Giving the quest reward

  • Add to when level starts set "reward given" false

{width="4.114583333333333in" height="0.8229166666666666in"}

  • Add to when touched another else if...

  • Else if 4 orcs killed = true and reward given = false

  • Display chat Thanks have reward 3 potions

  • Repeat 3 times, broadcast give Health Potion

{width="6.5in" height="1.8611111111111112in"}

  • Add another else if...

  • Else if reward given = true, broadcast display chat with "Thanks

    again for saving us!"

{width="6.5in" height="1.3055555555555556in"}

Making "give Health Potion" do something

  • Edit player script

  • When I receive "give Health Potion", broadcast "health potion"

  • (we will improve this next week with an inventory system)

{width="3.78125in" height="1.3020833333333333in"}

Week 6: Inventory

Add inventory panel

  • Add it to interface layer

  • Open chat box script, click menu, export, select all, copy, close

    script

  • Add script to inventory panel, menu, import, paste

  • Change textfield text to "INVENTORY"

  • Replace "when I receive message" with "When key I pressed" and

    remove "Set text"

  • Play game

{width="4.916666666666667in" height="5.208333333333333in"}

Repositioning inventory

  • Change offsets

{width="6.5in" height="2.5in"}

Disabling inventory with i key

  • Add "if else", if visibility = false, do activate blocks, else do

    deactivate blocks

{width="5.302083333333333in" height="3.7916666666666665in"}

Adding health potion icon to inventory

  • Place new health potion next to inventory panel

  • Add script, when level starts, disable physics, add tag "health

    potion icon"

{width="4.75in" height="1.4583333333333333in"}

  • Edit inventory script

  • Add set instance health potion icon to first instance tag health

    potion icon

{width="6.5in" height="0.6388888888888888in"}

  • Duplicate set x and y position blocks for health potion icon

    positioning constantly

{width="6.5in" height="1.1111111111111112in"}

  • Play game to see how it's positioned

{width="6.5in" height="0.5277777777777778in"}

  • Error! Because "when level starts, find health potion tag" is

    happening before "add tag".

  • On health potion icon, replace when level starts with when created

{width="4.489583333333333in" height="1.375in"}

  • Play game again

Functions for visibility instead

  • Put them in functions

  • Add visibility for health potion icon

{width="6.0in" height="7.1875in"}

Textfield for item count

  • Copy paste the same blocks for the first textfield with some tweaks

  • Change textfield by creating new var called textfield health potion

    count

  • Set number health potions to 0

  • Constantly position the count textfield

{width="6.34375in" height="2.3125in"}

{width="6.229166666666667in" height="0.65625in"}

{width="6.166666666666667in" height="0.5in"}

{width="6.5in" height="1.0694444444444444in"}

Receiving health potions

  • When I receive give Health Potion

  • Increase potions by 1

  • Set textfield health potion count to

  • Create text with number of potions, " x Health Potion"

{width="6.5in" height="1.2777777777777777in"}

Adding collectables to inventory instead

  • Edit collectable potion

  • Use "give" instead

{width="4.020833333333333in" height="0.7604166666666666in"}

Click to use potions in inventory

  • When player presses, instance health potion icon

  • If icon is visible

  • If health potions > 0

  • Broadcast use Health Potion

  • Decrease potions by 1

  • Set text of textfield health potion count to update (copy paste)

  • Broadcast display chat You used potion!

{width="6.5in" height="2.4444444444444446in"}

  • Update player script for "use Health Potion"

{width="3.71875in" height="0.7604166666666666in"}

Change how objects overlap in front of each other

  • Add tag inventory on inventory When created

{width="4.40625in" height="1.75in"}

  • Edit chatbox script

  • Add these to when level starts:

  • Myself move in front first instance tag inventory

  • Textfield move in front myself

{width="6.03125in" height="1.21875in"}

Week 7: Doors, teleporters, menu screens

Adding levels

  • Add levels

  • Rename them (start, level 2, game over, you win, etc)

  • Drag them into correct order

  • Resize them to match 960x540

  • Draw stuff in them appropriately

{width="6.5in" height="3.861111111111111in"}

Start button

  • Add script to start button object (can be anything)

  • When player presses myself

  • Go to next level

{width="3.3229166666666665in" height="1.2604166666666667in"}

Game over screen

  • Edit player script

  • Whenever player dies, change "go to last level" or level number

    (remember the level order, and first level is 0, next level is 1, after that is 2, etc.)

{width="4.135416666666667in" height="1.3541666666666667in"}

  • Add script to button in game over level

  • When player presses myself, go to first level

{width="2.7395833333333335in" height="1.1354166666666667in"}

You Win screen

  • Same as Game Over, except trigger on a new collectable object, or

    when a particular quest is completed

{width="5.0625in" height="1.6145833333333333in"}

Or

{width="6.114583333333333in" height="1.6145833333333333in"}

Doors

  • Place door in items layer, use arrow keys to nudge

  • Place doorway sides in tilemap

  • New layer "above" for doorway top arch

  • Add non-solid script to arch

  • Add script to door

  • When level starts immovable

  • When touched by player

  • Broadcast display chat with "The door creaks open..."

  • Play animation "open"

{width="6.239583333333333in" height="3.3125in"}

  • Play test, see it's too tight

  • One doorway side/wall side of door should go on a non-solid tilemap

    so you can walk through it like so

{width="2.4583333333333335in" height="2.3645833333333335in"}

  • Play test

Teleporters/stairways

  • Place stairs somewhere

  • Add script

  • When level starts, set immovable true

  • When touched by player,

  • New global variable (explain global vars) player starting x position

    and player starting y position

  • New property variable (explain property vars) "send player to this x

    position" "send player to this y position"

  • Go to level,

  • New property variable "send player to this level"

{width="6.5in" height="2.8472222222222223in"}

  • Script properties, tick public on these three

{width="5.083333333333333in" height="1.6354166666666667in"}

  • Close and save teleporter script

Find the coordinates in the level

  • Find the coordinates where you want to send the player

  • Type those in the Object Behaviour

Make the player go to that position

  • Edit player script, add to when the level starts...

  • Set x position of myself to (global var) player starting x position

  • Same for y position

{width="6.197916666666667in" height="1.09375in"}

  • Play game to test it... oh no what happens if the global var hasn't

    got a value yet??

  • Better add something to check if it has a value or not

  • Wrap those blocks in "If number player starting x position does not

    = null" (explain null as valueless)

{width="6.5in" height="1.5416666666666667in"}

Week 8: Finishing and Publishing

Work more on your level designs

  • Work time and problem solving time

Do the extension activities

  • Do the extension activities if you have time

How to Publish

  • Click Publish

  • Share the link

  • When you change your game, you'll need to Publish again

//Extension ideas

Chests

  • Making chests open and give items...

Solid props you can push around that don't slide

  • Add another script to another object

  • When level starts,

  • set drag x to 500, drag y 500, mass 100, elasticity 1

  • Note: you can play with these numbers but you might get weird stuff

    happening...

{width="2.2604166666666665in" height="2.21875in"}

  • Close script and save "movable solid object"

  • Add this script to things you want to push around

Other ideas

  • Snapping camera to level bounds

  • Keys for doors

  • Switch for spikes

  • Chests that give you items when opened

  • Breakable pots and crates and pillars

  • Breakable tables

  • Racks with removable weapons

  • Fade transitions when teleporting

  • Persistent game states (dead NPCs stay dead between levels)

  • Dark spooky overlay

  • Red damage overlay

  • Simple white circle particle effect for combat

  • Constantly if key pressed instead of when key pressed

  • Comprehensive animation states for player

  • Adjust chase velocity of NPCs by using multipliers and max velocity

  • Comprehensive animation states for NPCs

  • Additional patrolling state for NPC enemies

  • Add scaredy cat enemy NPCs that run away instead of chasing

  • Falling in holes

  • Instance properties with public variables for varying individual

    NPCs

  • Convert damage amounts from properties of NPC and player to send

    message with value system (so different NPCs can do different amounts of damage, or different player weapons deal different damage)

  • Offset textfields, change font typeface, change colour, etc

  • Display chat for anything collected, anything interesting that

    happens, etc

  • Add Gold system similar to health system

  • Make friendly NPCs wander around

  • YES and NO options on chat box

  • Make textfields ordered nicely by using move in front/move behind

  • Uploading your own sprites

  • explosions/particle effects

  • Get the archer firing arrow

results matching ""

    No results matching ""