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

Messages - Belligerent Gnome

#1
Ah, thanks so much!  ;D
#2
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.
#3
Okay, using a few arrays I was able to get it working. Now, when I press "Q", it sets my array to 1. When the array is 1, it runs the animation, allowing me to replace the condition "cChar.Loop" with "whatever == 1".
I then altered:

"if (!cChar.Animating && cChar.Loop > 3) cChar.Loop -= 4;"
to
"if (!cChar.Animating && cChar.Loop > 3){
cChar.Loop -= 4;
whatever[player.ID] = 0;
}"

It's a bit more complex, and I still have no idea why AreThingsOverlapping won't co-operate with "cChar.Loop", but it's working. I'm sure that there's an easier way to do this, but when it comes to programming I have a tendency to do things in a very roundabout way. Oh, and it's an array because it will be commonly used by several characters. Thanks for your help.
#4
Well, the first number gets higher the closer cChar gets to cChar1 (up to 28), and the second number only goes up to four when the loop is running but seems to randomly jump to four when it isn't.

I'm going to try working at this from a different angle, I'll keep you posted.
#5
The debugger seems to take notice, both numbers go up pretty high when cChar gets close.
#6
Well, that gets it to animate without the blocking on, but there's still no reaction from cChar1.  :-\
Sorry for all the trouble.
#7
Sure.

function on_key_press(eKeyCode keycode)
{
if (keycode == eKeyQ)
  {
    cChar.LockView(1);
    cChar.Animate(4, 0, eOnce, eBlock, eForwards);
    cChar.UnlockView();
    cChar.Loop = 0;
  }
}

Does on_key_press run every game loop? Sorry, I'm something of a n00b.  :P
#8
Ah, yes! Now I remember using the repeatedly_execute_always function. It still isn't working, but I tested it with the block on once and it closed with an error when I tried to animate during the collision, which is a good sign if only for the fact that it means it's paying attention to the code. Now the problem is that, for some reason, it won't animate if the block isn't on. Is there a way to solve that? Thanks for your help, by the way.
#9
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