Log In  


Cart #39610 | 2017-04-13 | Code ▽ | Embed ▽ | No License
3

Here's a WIP for the 1-Bit Clicker jam, the HP drop for the rat has been sorted, somehow there's an issue in the attack function where I'm mixing up actors A,B with P(player) and Rat, just when I thought I was sorted :s

Shout out to the guys in this thread and comments below for your help and patience.

To do:
-adding more enemies
-click counter for enemies' hp (with a bar)
-effects and juice
-music/sfx
-more gameplay if time (penalties for player)
-start/gameover screens

3


I can't tell if this is what you have or what you're going for, but you could have a system like this to make sure damage is only done on the first frame of clicking:

if click then
if mouseInput == 0 then
mouseInput = 2
else mouseInput == 2 then
mouseInput = 1
end
else
mouseInput = 0
end


Hi Jclermont,

Thanks for the tip, I tried to implement it but couldn't make it work. I think I understand the idea of using the mouseInput as a switch but wasn't sure in which function and where to call the variable mouseinput first. Should that be in the global ? init ? or a local variable ?

I've just updated the cart to streamline the code with the help of ElGregos.

Thanks again !

K.


Looking at the code above I see that in the function attack() you iterate over all actors while iterating over all actors. This creates what my mom calls "a Cartesian Product", another example is a multiplication table. Ever notice how they have both 1*2 and 2*1 ? Why is that?
I think what's happening is that it detects the collision twice, once with a set to the hand and b set to the rat and again the other way around, with a as the rat and b the hand, both get processed in the same frame while clk is still 1, so rat.hp get dec'd twice
EDIT: removing the hidden block. Don't post right after waking up kids ;)


codlark is right, that's why rat's energy decrease by 2 instead of 1: because hand hits rat first, then rat hits hand.


Codlark & ElGregos > Dang! that makes total sense !

After fiddling with this function and not finding a logical way to fix it, I actually just replaced rat.hp by b.hp, and miraculously (beyond my knowledge) it works !!!

function attack()
 for a in all(actors) do
  for b in all(actors) do
   if (check_coll(a,b)==true and clk==1) then 
    b.hp-=1
    if (rat.hp<=0) then 
     del(actors,b)
    end
   end
  end
 end 
end

Now, and as if I was sorted, when I changed the rat.hp<=0 by b.hp it now deletes the hand... I probably need to tweak that collision and make sure I know what a and b refers to in the game :/

I've updated the game with the tweak btw.

Anyway, a thousand thanks guys for pointing that out !


Update:

There's definitely an issue with the actors in the collision function both player and rat hp are affected as they share the same make_actors function, which will be an issue down the line when adding more enemies.

Do you think I should make lists for different enemy types ?



[Please log in to post a comment]