Saturday, March 17, 2012

Experimentation with Crafty and vehicles

Have nearly decided to go with overhead view for initial prototyping to get game mechanics worked out.
Was experimenting with (free) Crafty game engine and whipped up a demo of showing difference in steering between wheeled and tracked vehicles.  Most RTS games I have seen use 'tracked' vehicle movement in that they point in a direction...move...stop briefly to rotate then move again.  Crafty had a GTA style (overhead) view that included driving a car that implemented handling and steering, so I thought I'd whip up a demo of showing the difference.
The code for the 'wheeled' steering looks something like this:


                if(keyLeft){
                    dozer.rotation.y += _speed * _handling 
                }
                if(keyRight){
                    dozer.rotation.y -= _speed * _handling 
                }
                if(keyUp){
                    startScanning = true;
                    _speed += _acceleration;
                }
                if(keyDown){
                    _speed -= _acceleration;
                }
                _speed = _speed * 0.98;
                if(_speed > _maxSpeed) {
                    _speed = _maxSpeed;
                }
                if(_speed < -1) {
                    _speed = -1;
                }
                dozer.position.x -= Math.cos(dozer.rotation.y ) *( _speed);
                dozer.position.z -= Math.sin(dozer.rotation.y ) * -_speed;

1 comment:

  1. Note that I was informed by friends that modern tracked vehicles CAN 'steer' without stopping by slowing instead of stopping one track..

    Example:
    http://www.youtube.com/watch?v=PyKktpTwr1c&feature=relmfu

    ReplyDelete