R0J0hound's Recent Forum Activity

  • Here is an example of a field of view engine using the image manipulator. I just used over sized pixels for the example but it is easy enough to use sprites instead. The advantage of using the image manipulator as opposed to a canvas is a very small amount of memory is used (a 20x30 pixel image for a 640x960 pixel layout with 32 pixel tiles).

    Enjoy

  • Here is a python script for ease in and out camera motion.

    class myscroll:
    	def __init__(self):
    		self.acceleration=100;		
    		self._ax=0;	self._ay=0
    		self._vx=0;	self._vy=0
    
    	def __call__(self, obj):
    		myscrollx=(System.ScrollXLeft+System.ScrollXRight)/2
    		myscrolly=(System.ScrollYTop+System.ScrollYBottom)/2
    
    		# x motion
    		diff=obj.X-myscrollx
    		if abs(diff)<1:
    			self._ax=0;  self._vx=0
    		else:
    			if self._vx**2/(2*self.acceleration) >= abs(diff):
    				self._ax=-1*cmp(self._vx,0)*self.acceleration
    			else:
    				self._ax=cmp(diff,0)*self.acceleration
    
    		# y motion
    		diff=obj.Y-myscrolly
    		if abs(diff)<1:
    			self._ay=0;  self._vy=0
    		else:
    			if self._vy**2/(2*self.acceleration) >= abs(diff):
    				self._ay=-1*cmp(self._vy,0)*self.acceleration
    			else:
    				self._ay=cmp(diff,0)*self.acceleration
    
    		self._vx+=self._ax*System.TimeDelta
    		self._vy+=self._ay*System.TimeDelta
    		System.ScrollX(myscrollx+self._vx*System.TimeDelta)
    		System.ScrollY(myscrolly+self._vy*System.TimeDelta)
    myscroll=myscroll()[/code:2fwplqvv]
    No need to understand how it works, just have that script run at the "start of layout" and call "myscroll(Sprite)" every tick.  The only setting is acceleration, which can be changed at any time with the script "myscroll.acceleration=400".
    
    Basically what it does is accelerate the camera to the object and then decelerate so that when the screen arrives at the object the camera speed will be zero.
    
    Example of use: [url]http://dl.dropbox.com/u/5426011/examples/camera%20easeinandout.cap[/url]
    req at least 0.99.84
    
    Feel free to use or enhance.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • A solution for the jitter would be to stop the motion and point to the target when the angle difference and angular velocity are lower than some thresholds.

    Add this event to the "targeting" group:

    + System: AngleDiff(turret.Angle, turret ('target')) Lower than 0.5
    + System: abs(turret[Physics].AngularVelocity) Lower than 0.2
    -> turret: Set torque 0
    -> turret: Set angular velocity to 0
    -> turret: Set angle to 'target'[/code:1pqycuqz]
  • Finally got an example for a physics turret working:

    http://dl.dropbox.com/u/5426011/examples/PhysicsTurret.cap

    and tweaked so it works with multiple turrets:

    http://dl.dropbox.com/u/5426011/examples/multiPhysicsTurret.cap

    The only drawback is the turret's inertia needs to be calculated (which I do in the first second). Also the calculated inertia is not 100% accurate so the turrets jitter a bit when pointing at the target.

    -enjoy

  • Here's an example made by Rich :

    http://www.scirra.com/forum/viewtopic.php?f=16&t=2210

  • Here's another way to do it:

    Initially give "Sprite" the attribute solid. Sprite only needs 1 private variable 'time'.

    EDIT:

    Also add a box object and add it to a container with sprite. The box objects will serve as the collision detection for sprite because when sprite is set to no collision an overlapping condition can never be true.

    Here's what I came up with:

    http://dl.dropbox.com/u/5426011/examples/hideplatform.cap

  • Constant 8 fps

    Pentium 3 866 Mhz

    512 Mb Ram

    Nvidia GeForce FX 5200 (128 Mb)

  • The nice thing about using behaviors is you don't need to worry about TimeDelta, because it's handled within the behavior.

    You can simplify your events and it will behave exactly the same and be more readable:

    + MouseKeyboard: Key Up arrow is down
    -> Sprite: Set force Sprite.value('Thrust') towards (Sprite.X + cos(Sprite.Angle), Sprite.Y + sin(Sprite.Angle))
    + MouseKeyboard: Key Left arrow is down
    -> Sprite: Set torque 0-Sprite.value('Rotation')
    + MouseKeyboard: Key Right arrow is down
    -> Sprite: Set torque Sprite.value('Rotation')[/code:1fvwdf3w]
  • Sagal's right, just use the "every" condition, much simpler. I compared the two methods and found that they behaved pretty much the same. I'm continuously impressed on how so many tasks are very simple to do in construct.

  • Actually the 200 and 100 are linear and angular acceleration, not speeds.

    For angular deceleration:

    + MouseKeyboard: [negated] Key Left arrow is down
    + MouseKeyboard: [negated] Key Right arrow is down
    -> Sprite: Subtract 2*'AngularVelocity'*TimeDelta from 'AngularVelocity'
    [/code:3q26kvpc]
    2 is the deceleration amount .
    
    On a side note the physics behavior is way better suited for this type of movement, as it takes very little to set up.
  • For that type of movement only addition and subtraction of vectors are needed. No need for dot or cross product although those are easily implementable.

    Here's an example for you viewing pleasure:

    http://dl.dropbox.com/u/5426011/examples/asteroidsMovementEx.cap

  • Must sleep so here's the example (might explain later):

    https://www.dropbox.com/s/3mlg8usurpq45 ... d.cap?dl=1

    /examples/fake3droad.cap

    Enjoy.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound