Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Mission 9

User Controls

https://roderickvella.wordpress.com

Mission Objectives
Welcome to your 9th mission. In this
mission we are going to learn how use
button pressed commands.

Button Pressed
Something happens when the user
presses a button.

Mission 9 : Prog 1
In this example we are going to output
a message on the screen for varies
buttons pressed by the player.

Step 1

Notes on Mission 9: Prog 1


Line 142

while(true)

Infinite loop that keeps checking for any


inputs

Line 144

If the player presses the attack button


if (self
attackButtonPressed() ) (left click), something will happen

Line 149

if( self
adsbuttonpressed())

If the player presses the Aim Down Sight


(right click), something will happen

Line 154

if( self
meleeButtonPressed() )

If the player presses the melee button


(V), something will happen

Line 159

if( self
fragbuttonpressed())

If the player presses the grenade button


(middle mouse), something will happen

Line 164

if(self
UseButtonPressed())

If the player presses the use button (f),


something will happen

Line 169

wait(0.05);

Slows down the loop so that the


buttonpressed function can have time
to register that something is pressed

Mission 9 : Prog 2
In Mission 9 Prog 1 we have a small
problem.
Although the player presses a particular
button only once, COD interprets this as
if the player presses the button multiple
times. Lets see a video to better
understand the problem.

Mission 9 : Prog 2

Mission 9 : Prog 2
In this mission we are going to solve
this problem.
We are going to test this on the Aim
Down Sight button.

Step 1

Mission 9 : Prog 2

Mission 9 Task 1
Fix the following code. When the player presses
the attack button, the screen should get more
blurred. The end result should be like in the
video.

Mission 9 Task 1

Mission 9 Task 1

You might also like