Darkness/Lantern effect and Bounce-Pads

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

User avatar
Froginator
Slime Knight
Posts: 188
Joined: Thu Apr 24, 2014 10:13 pm
Location: Germany
Contact:

Post by Froginator »

Yeah.. what I'm trying to do is that the cave can be entered and exited at any time. The darkness inside should stay, but the problem is when you exit the cave, every map now has the black overlay.

And here's the mushroom script btw:

Code: Select all

plotscript, shroomJumpRight, begin
 suspend player
  play sound (2)
  wait for sound (2)
  stop sound (2)
  variable (i, jump)
  set hero direction (me, right)
  jump := -5
  for (i, 0, 10) do (
    put hero (me, hero pixel X (me) + 4, hero pixel Y (me) + jump)
    jump += 1
    wait
  )
 resume player
end
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I think the problem with activating NPCs is that the hero becomes misaligned, because the hero moves 44 pixels in the x direction. Here's one modification that should work better:

Code: Select all

  variable (i, jump, startx) 
  jump := -5
  startx := hero pixel X (me)
  for (i, 1, 11) do (
    put hero (me, startx + 40 * i / 11, hero pixel Y (me) + jump)
    jump += 1
    wait
  ) 
Also, no need to put "stop sound (2)" after "wait for sound (2)"; it already waits until it's stopped.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Froginator wrote:Yeah.. what I'm trying to do is that the cave can be entered and exited at any time. The darkness inside should stay, but the problem is when you exit the cave, every map now has the black overlay.
Oh! I get it now!

So you need something kind of like:

Code: Select all

if&#40;current map <> map&#58;darkness map&#41; then&#40;
  #remove black layer here
  exit script
&#41;
That should go inside the while loop part of your darkness script, so it will check each tick whether or not you have moved to a different map.
User avatar
Froginator
Slime Knight
Posts: 188
Joined: Thu Apr 24, 2014 10:13 pm
Location: Germany
Contact:

Post by Froginator »

Thanks for the help! The Mushroom script works perfectly now.

But there's one thing with the Darkness script. It's probably my fault though.
I think I'm putting things at the wrong places because here's what I did:

Code: Select all

global variable &#40;1, flashlight circle&#41;
plotscript, setup flashlight, begin
  flashlight circle &#58;= load backdrop sprite &#40;5&#41;
  if&#40;current map <> #Waterfall Cave#&#41; then&#40;
  exit script
&#41;
end
I also tried putting it in front of the "flashlight circle := load backdrop sprite (5)" and also tried using free sprite but I'm probably doing it all wrong. So I'd rather have someone help me instead of more trial and error. What could also be a problem is that the map name IS #Waterfall Cave# and HSS reads it as a comment written with a # in front of it..
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Ah, I have again misunderstood. I should have just asked you to post the script in the first place.

I assumed that you had some kind of "while" loop that was updating the flashlight circle every tick as long as your are in the map.

With no "while" loop, then all my talk about "exit script" is totally unhelpful.

You will want

Code: Select all

free sprite&#40;flashlight circle&#41;
In the script that runs after you leave the dark map
User avatar
Froginator
Slime Knight
Posts: 188
Joined: Thu Apr 24, 2014 10:13 pm
Location: Germany
Contact:

Post by Froginator »

Awesome! Everything works now! Thank you so much!

So now that I got both mushrooms for left and right done, I'm trying to make two for up and down.
I think I got some of the values wrong because what happens is that the chracters fly in some kind of black void when I use the shroom..?

Code: Select all

plotscript, shroomJumpDown, begin
 suspend player
  play sound &#40;2&#41;
  wait for sound &#40;2&#41;
  variable &#40;i, jump, starty&#41;
   jump &#58;= -5
   starty &#58;= hero pixel Y &#40;me&#41;
   for &#40;i, 1, 11&#41; do &#40;
    put hero &#40;me, starty + -60 * i / 11, hero pixel X &#40;me&#41; + jump&#41;
    jump += 1
    wait
  &#41;

 resume player
end
What I did is basically just change every X to a Y because it worked in a script where I used X and Y as well before but this doesn't seem to be the correct solution..
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

I think you should be using "set hero z"

Normally, heroes are always a z=0

z doesn't affect your actual x,y position on the map, just changes how far above the tile the sprite is drawn
User avatar
Froginator
Slime Knight
Posts: 188
Joined: Thu Apr 24, 2014 10:13 pm
Location: Germany
Contact:

Post by Froginator »

So I should replace the "jump" stuff with a simple change of the Z axis and then replace the Xs with Ys?
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Oh, yeah, it's definitely best to use Z. Note the Z position increases upwards, while Y [s]decreases[/s] (edit: increases) towards the bottom of the screen.

Code: Select all

# Makes the hero jump in an arc and move so many pixels in the X and Y directions
script, shroomJump, x total, y total, begin
  suspend player
  play sound &#40;2&#41;
  wait for sound &#40;2&#41;
  variable &#40;i, jump, startx, starty&#41;
  jump &#58;= 5
  startx &#58;= hero pixel X &#40;me&#41;
  starty &#58;= hero pixel Y &#40;me&#41;
  for &#40;i, 1, 11&#41; do &#40;
    put hero &#40;me, startx + x total * i / 11, starty + y total * i / 11&#41;
    set hero Z&#40;me, hero Z&#40;me&#41; + jump&#41;
    jump -= 1
    wait
  &#41;
  resume player
end

plotscript, shroomJumpDown, begin
  shroomJump&#40;0, 60&#41;
end

plotscript, shroomJumpUp, begin
  shroomJump&#40;0, -60&#41;
end

plotscript, shroomJumpLeft, begin
  shroomJump&#40;-60, 0&#41;
end

plotscript, shroomJumpRight, begin
  shroomJump&#40;60, 0&#41;
end
Last edited by TMC on Thu Jun 09, 2016 11:11 pm, edited 1 time in total.
User avatar
Froginator
Slime Knight
Posts: 188
Joined: Thu Apr 24, 2014 10:13 pm
Location: Germany
Contact:

Post by Froginator »

Ah I get it! Thank you! Works perfectly now!
Post Reply