Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


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.

Messages - hex

Pages: [1]
1
Technical forum / Re: Editor Filter
« on: July 01, 2012, 06:30:51 AM »
Ah, I see what Mnemonic meant by catching the change to the editor. Didn't realize that was possible. Very helpful, thanks :)

For anyone needing this filter, append an equal sign to the operators to capture the letters Aa and Zz: <=, >=

2
Hello again :)

I put this problem on hold while working on other parts of the game, but now it's become a showstopper.

Latest update: I'm going with the time-elapsed method since you both agree it's the right way. But won't the time elapsed always be 20, or whatever the number is in the Sleep function? In the game loop, I have two lines that store the last frame's time, and the time elapsed:

Code: WME Script
  1.   gTimeElapsedSinceLastFrame = Game.CurrentTime - gTimeLastFrame;
  2.   gTimeLastFrame = Game.CurrentTime;
  3.  

gTimeElapsedSinceLastFrame always equals 20.  Assuming this is correct (I'm guessing it isn't), the next step is to multiply gTimeElapsedSinceLastFrame by dirX and dirY (the speed), right? The resulting movement is very jittery and not smooth at all. Also, it never reaches its destination because it never meets the while loop's condition (although this is probably an easy fix).

Code: WME Script
  1. method LinearMovement(movingEntity, startX, startY, endX, endY)
  2. {
  3.         var dX = Math.Abs(endX - startX);
  4.         var dY = Math.Abs(endY - startY);
  5.        
  6.         var dirX = 1;
  7.         if (startX > endX)
  8.                 dirX = -1;
  9.                
  10.         var dirY = 1;
  11.         if (startY > endY)
  12.                 dirY = -1;
  13.        
  14.         dirX = dirX * gTimeElapsedSinceLastFrame;
  15.         dirY = dirY * gTimeElapsedSinceLastFrame;
  16.                
  17.         var diff = dirX - dirY;
  18.        
  19.         var posX = startX;
  20.         var posY = startY;
  21.        
  22.         while ((posX != endX) && (posY != endY))
  23.         {
  24.                 var dblDiff = 2 * diff;
  25.                
  26.                 if (dblDiff > (-1 * dY))
  27.                 {
  28.                         diff = diff - dY;
  29.                         posX = posX + dirX;
  30.                 }
  31.                
  32.                 if (dblDiff < dX)
  33.                 {
  34.                         diff = diff + dX;
  35.                         posY = posY + dirY;
  36.                 }
  37.                
  38.                 movingEntity.X = posX;
  39.                 movingEntity.Y = posY;
  40.                
  41.                 Sleep(20);
  42.         }
  43.        
  44.         movingEntity.X = endX;
  45.         movingEntity.Y = endY;
  46. }
  47.  

3
Technical forum / Re: Editor Filter
« on: June 02, 2012, 11:42:51 AM »
Hello Venom, were you able to filter character input? If so, how? I don't want the player to submit only a blank "space" without letters.

4
Technical forum / Re: Keyboard key "P" always pause the game
« on: May 24, 2012, 05:56:37 AM »
Same thing here and I'm using a laptop. Pressing the P key brings up the main menu (based on the default code in game.script).

Deleting the VK_F1 line in the if statement took care of the problem, but it also means I can't use the F1 key without the P key performing the same function. So for some reason, VK_F1 detects P keypresses.

Not an issue for me because I don't plan on using the F1 key at the moment, but it's just a FYI for anyone having this problem.

5
Technical forum / Re: Moving non-actor entities towards an XY position
« on: March 12, 2012, 03:03:24 AM »
Thanks for explaining the Sleep function. I need Sleep() inside of a while loop for Game.CurrentTime to be updated, correct? I tried this:

Code: [Select]
var timeLastFrame = Game.CurrentTime;
var timeElapsed = 0;
var loopCounter = 0;
while (loopCounter < 2)
{
timeElapsed = Game.CurrentTime - timeLastFrame;
loopCounter = loopCounter + 1;
Sleep(20);
}

Printing the output to the screen, timeElapsed is equal to 0 the first time, then about 30 the second time, depending on what number I use in the Sleep function.

How does timeElapsed relate to the while loop inside the LinearMovement function? My game runs at 56 - 60 FPS full screen.

6
Technical forum / Re: Moving non-actor entities towards an XY position
« on: March 07, 2012, 12:17:28 AM »
I'm not sure how the Sleep function works. The pieces move very slowly when I enter any value greater than or equal to 1 (it was at 20 first). Just to experiment, I put 0.99 and the pieces moved very quickly. So they either move super fast or super slow.

Strangely, the Sleep function was working fine at first..

7
Technical forum / Re: Is it possible to use no actor?
« on: March 07, 2012, 12:10:04 AM »
Are you making a first-person game? I'm not sure if this is the best way to do it, but perhaps you can use a small, blank, transparent bitmap image in your player.entity's sprite.

8
Technical forum / Re: Moving non-actor entities towards an XY position
« on: March 03, 2012, 05:38:47 AM »
Thank you so much, metamorphium! This worked  :D

The only thing I had to change was a slight typo: var posY = startY;

9
Technical forum / Re: Moving non-actor entities towards an XY position
« on: March 02, 2012, 02:12:08 AM »
Thanks jackslawed, though I think I would still need an if statement to check if X or Y is greater/less than to make sure the object is moving in the correct direction (+ / -)

But yes, I need some equation to get the object moving at equal speeds on both axis!

10
Technical forum / Moving non-actor entities towards an XY position
« on: March 01, 2012, 09:26:39 AM »
Hi all,

I have a puzzle set up with a few objects (entities) and hotspots (regional entities). When you click on an object, I enable the vacant hotspots that the object can move in to.

Instead of simply skipping to the new location, I would like the objects to "slide" over to the new XY positions. I need something similar to the GoTo method for actors, but for entities.

I tried the following, but the object doesn't move smoothly a straight path, which I can understand why is happening. (It's reaching it's new X position before the Y position, or vice versa)

To explain the code:
EyesActivePiece = the puzzle piece that needs to move
this = the hotspot you click on that contains the object's new XY coordinates
cpX and cpY = the hardcoded X and Y coordinates of the hotspot that the object must move towards

I really appreciate your help. Thanks!

Code: [Select]
var moving = true;
while (moving)
{
if (this.cpX > EyesActivePiece.X)
EyesActivePiece.X = EyesActivePiece.X + 1;
else
EyesActivePiece.X = EyesActivePiece.X - 1;

if (this.cpY > EyesActivePiece.Y)
EyesActivePiece.Y = EyesActivePiece.Y + 1;
else
EyesActivePiece.Y = EyesActivePiece.Y - 1;

if ((EyesActivePiece.X == this.cpX) && (EyesActivePiece.Y == this.cpY))
moving = false;

Sleep(5);
}

Pages: [1]

Page created in 0.053 seconds with 25 queries.