Explanations:
How
do spikes reduce the player's HP?
First,
I place a collision event on the spikes.
Collision
> Top Side of Player > Script Editor
The
collide actor tells the program that the effect will occur when
the top side of the player collides with the spikes facing down.
In other words, when the player's head hits the spikes. Then
it will execute the script editor, where I enter my own code:
hp.textNumber
= hp.textNumber -12;
The
actor "hp" is the text you see on the top left of
the screen. (An actor is basically equavalent to an atom in
real life - everything is generated from it. It doesn't have
to be just a "character.") This code tells the textNumber
to decrease by 12. In other words, you lose 12 hp by hitting
the spikes.
How
does that gun blow out toxic smoke that will affect the player?
(You will see the gun mounted to the wall near the upper left
of the first picture.)
Basically,
the gun "actor" isn't actually doing anything codewise.
There is the element called "paths" in this program.
It's kind of like a railroad track - it will direct the train
where to go. The same goes with a path. I have set a path to
go diagonally down-right. The toxic smoke actor is set to follow
the path - it's another easy function to do in Game-Editor.
There is actually very little coding in this mechanism, except
for damage the player receives when it hits the smoke.

Unless told not to, a path "resets" back to it's starting
point at the end. In other words, when an object following the
path reaches the end of the "track" the object suddenly
"teleports to the beginning, and the same process continues.
Hence, the repeating blow of the smoke.