This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-02-13 16:00:02

Un_Pinguino_Perdido
Scratcher
Registered: 2010-02-13
Posts: 3

Help with Lives/Sensing on 2d adventure game!

I'm trying to make a 2d adventure type game (a lot like the original legend of zelda type games). So far it's been going really well, but the biggest problem I've run into is dealing with lives of enemies and the main charecter. I have it set up as a variable with the heart icons as sprites, and when an enemy is touching the main charecter, then the life variable changes by -1 and one of the hearts disappears. The problem is, once the enemy is touching the player, all of the hearts get drained. How would I make it so that the player has a few seconds of immunity before losing another life?

And for enemy health, I'd like to set it up so every time you go through the attack animation (which is the player bashing the enemy with a stick) it drains only one of the enemies lifes?

Any help would be greatly appreciated! smile

Offline

 

#2 2010-02-13 16:16:23

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Help with Lives/Sensing on 2d adventure game!

Un_Pinguino_Perdido wrote:

I'm trying to make a 2d adventure type game (a lot like the original legend of zelda type games). So far it's been going really well, but the biggest problem I've run into is dealing with lives of enemies and the main charecter. I have it set up as a variable with the heart icons as sprites, and when an enemy is touching the main charecter, then the life variable changes by -1 and one of the hearts disappears. The problem is, once the enemy is touching the player, all of the hearts get drained. How would I make it so that the player has a few seconds of immunity before losing another life?

And for enemy health, I'd like to set it up so every time you go through the attack animation (which is the player bashing the enemy with a stick) it drains only one of the enemies lifes?

Any help would be greatly appreciated! smile

Hmm - for the immunity you should use the timer blocks. Put the player's take damage script under this:

<if><( <timer> <>> How long invincibility lasts )>
Script goes here
<end>

And when the player takes damage it should reset the timer:

<reset timer>

I don't understand what you mean by the second question, though.  hmm

Last edited by RHY3756547 (2010-02-13 16:17:47)

Offline

 

#3 2010-02-13 16:42:08

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Help with Lives/Sensing on 2d adventure game!

RHY3756547 wrote:

Un_Pinguino_Perdido wrote:

I'm trying to make a 2d adventure type game (a lot like the original legend of zelda type games). So far it's been going really well, but the biggest problem I've run into is dealing with lives of enemies and the main charecter. I have it set up as a variable with the heart icons as sprites, and when an enemy is touching the main charecter, then the life variable changes by -1 and one of the hearts disappears. The problem is, once the enemy is touching the player, all of the hearts get drained. How would I make it so that the player has a few seconds of immunity before losing another life?

And for enemy health, I'd like to set it up so every time you go through the attack animation (which is the player bashing the enemy with a stick) it drains only one of the enemies lifes?

Any help would be greatly appreciated! smile

Hmm - for the immunity you should use the timer blocks. Put the player's take damage script under this:

<if><( <timer> <>> How long invincibility lasts )>
Script goes here
<end>

And when the player takes damage it should reset the timer:

<reset timer>

I don't understand what you mean by the second question, though.  hmm

The second question is asking how to make the attack only hurt the enemy once no matter how long the weapon touches the enemy.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#4 2010-02-13 16:55:04

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Help with Lives/Sensing on 2d adventure game!

juststickman wrote:

RHY3756547 wrote:

Un_Pinguino_Perdido wrote:

I'm trying to make a 2d adventure type game (a lot like the original legend of zelda type games). So far it's been going really well, but the biggest problem I've run into is dealing with lives of enemies and the main charecter. I have it set up as a variable with the heart icons as sprites, and when an enemy is touching the main charecter, then the life variable changes by -1 and one of the hearts disappears. The problem is, once the enemy is touching the player, all of the hearts get drained. How would I make it so that the player has a few seconds of immunity before losing another life?

And for enemy health, I'd like to set it up so every time you go through the attack animation (which is the player bashing the enemy with a stick) it drains only one of the enemies lifes?

Any help would be greatly appreciated! smile

Hmm - for the immunity you should use the timer blocks. Put the player's take damage script under this:

<if><( <timer> <>> How long invincibility lasts )>
Script goes here
<end>

And when the player takes damage it should reset the timer:

<reset timer>

I don't understand what you mean by the second question, though.  hmm

The second question is asking how to make the attack only hurt the enemy once no matter how long the weapon touches the enemy.

OK then. For that - put this in to the script:

<if><touching[ Player's Pointy Stick ]>
<change{ HP }by( Whatever )>
<wait until><not> <touching[ Player's pointy Stick ]>>
<end>

Last edited by RHY3756547 (2010-02-13 16:55:43)

Offline

 

#5 2010-02-14 01:36:32

Un_Pinguino_Perdido
Scratcher
Registered: 2010-02-13
Posts: 3

Re: Help with Lives/Sensing on 2d adventure game!

Took me a while to figure out the timer block, but now it's working great!
And I can't believe I didn't think of that second script...Thanks! smile

Offline

 

Board footer