Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Belligerent Gnome

#1
Shortly after my AreThingsOverlapping ordeal, I decided to start working on the gravity for my quite possibly futile attempt at a combat system. Obviously, the very fabric of fate appears to be against it, as I have now encountered yet another nonsensical error. Here is the code for the gravity:

function repeatedly_execute_always()
{
  catchY[player.ID] = 198;
 
  if (player.y != catchY[player.ID])
  {gravity[player.ID]= -1;
  player.y=player.y-gravSpeed[player.ID];
  gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];
 
  if (gravity[player.ID] < -1)
  gravity[player.ID] = -1;
}

  if (player.y > catchY[player.ID])
  player.y = catchY[player.ID];
 
  if (IsKeyPressed(eKeyUpArrow)==1)
  player.y -= 20;
  }

Now, "catchY" is an array I use in the place of a conventional floor. The "if" line underneath it stops the downward motion if the player is at "catchY" (meaning that it only simulates gravity instead of actually making it realistic, but whatever) while moving it downwards if it isn't. The next "if" statement keeps gravity from becoming uncontrollably fast. The next one basically keeps the player from falling through the floor, and the last one is simply for jumping.

So, my problem is this: I can jump once, everything seems dandy, then the character just freezes in midair, the sprite bottom at y coordinate 177. When I release the button, I simply teleport to catchY (which is 198), and every time I try to jump after that I just teleport up to 177 again.

Oddly enough, when I deleted this line (I think): 
gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];

And replaced the gravSpeed with gravity in the line before it, this no longer happened; however, understandably enough, I would no longer fall without releasing the button.

Sorry for the long post, but I've been stumped on this for months and didn't really see an alternative.
Thanks for putting up with my bizarre problems.
#2
Alright, so, here's the story.

I've been trying to invoke a reaction from one character when another does something while the two are colliding. I spent nearly an entire day trying to figure it out and eventually got it working before, but then my computer finally died and I lost it.  :-\  So I recently decided to start again, and it's generally been more organised than it's last incarnation, but then I hit that roadblock again. Here's the code I'm currently trying to get working:

if ((AreThingsOverlapping(CHAR, CHAR1)) &&
player.Loop == 4){
cChar1.LockView(4);
cChar1.Animate(0, 0, eOnce, eBlock, eForwards);
cChar1.UnlockView();
}

So I put this in the rep_exec portion of the room, but when I test it and trigger the animation during collision, there's no response from the other character. I've tried countless variations of the code, swapping the two conditions, changing the second one... I even dropped the AreThingsOverlapping in favor of other, similar things. But the only time it worked was when I dropped the player.Loop or equivalent code completely, leaving AreThingsColliding the only condition and making the entire point of the code obsolete. Like I said, I did it before, but only after spending several hours trying even after consuming two cups of coffee.

Help would be greatly appreciated.
SMF spam blocked by CleanTalk