Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 67

Thread: Pascal and XNA...

  1. #41

    Pascal and XNA...

    Here's an article that shows one way that could be used to get a Chrome game onto an XBox 360.
    http://grammerjack.spaces.live.com/b...8A7C!158.entry

    It basically involves make your game an assembly, then writing a C# dummy project in GSE that just calls your Chrome Game.main function and it should just work assuming everything else is setup correctly.

    Also if you want to know what people who know what they are doing can do with XNA in 4 days, check out Ben's entry into the GDC XNA Challenge. He tried to write a 3rd person RPG in 4 days. You can check out what he managed to do by visiting http://abi.exdream.com
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  2. #42

    Pascal and XNA...

    Ok I've tried a few things, but it's just not working correctly .

    This is the current state of the UpdateInput method.
    Currently when I press left or right without moving the model just rotates on the spot, it's a bit more realistic when it's moving, but still not perfect.

    Any ideas?

    [pascal]
    method TTank.UpdateInput( aGameTime : Gametime; aGamePadState : GamePadState; aKeyboardState : KeyboardState; aMouseState : MouseState ) : boolean;
    var
    tankVelocityAdd : Vector3;
    lTimeSeconds : single;
    lTimeMilliSeconds : single;
    begin
    result := true;
    lTimeMilliSeconds := aGameTime.ElapsedGameTime.TotalMilliseconds;
    lTimeSeconds := aGameTime.TotalGameTime.TotalSeconds;

    {$REGION GamePad}
    if ( aGamePadState.IsConnected ) then
    begin
    // Allows the default game to exit on Xbox 360 and Windows using a Gamepad
    if ( aGamePadState.Buttons.Back = ButtonState.Pressed ) then
    begin
    result := false;
    Exit;
    end;

    //rotate the model using the left thumbstick, scale it down
    tankRotation := tankRotation - aGamePadState.ThumbSticks.Left.X * 0.10;

    //create some velocity if the right trigger is down
    tankVelocityAdd := Vector3.Zero;

    //find out what direction we should be thrusting, using rotation
    tankVelocityAdd.X := -Math.Sin( tankRotation );
    tankVelocityAdd.Z := -Math.Cos( tankRotation );

    //now scale our direction by how hard the trigger is down
    tankVelocityAdd := tankVelocityAdd * aGamePadState.Triggers.Right;

    //finally, add this vector to our velocity.
    tankVelocity := tankVelocity + tankVelocityAdd;

    GamePad.SetVibration( PlayerIndex.One, aGamePadState.Triggers.Right, aGamePadState.Triggers.Right );

    //in case you get lost, press A to warp back to the center
    if ( aGamePadState.Buttons.A = ButtonState.Pressed ) then
    begin
    tankPosition := Vector3.Zero;
    tankVelocity := Vector3.Zero;
    tankRotation := 0.0;
    end;
    end;
    {$ENDREGION}

    {$REGION Keyboard}
    if Assigned( aKeyboardState ) then
    begin
    // Allows the default game to exit on Xbox 360 and Windows using a Keyboard
    if ( aKeyboardState.IsKeyDown( Keys.Escape ) ) then
    begin
    result := false;
    Exit;
    end;

    //in case you get lost, press Spacebar to warp back to the center
    if ( aKeyboardState.IsKeyDown( Keys.Space ) ) then
    begin
    //Key has just been pressed
    tankPosition := Vector3.Zero;
    tankVelocity := Vector3.Zero;
    tankRotation := 0.0;
    end;
    // otherwise, check to see we are moving left, right forward backward
    // (and therefore just released)
    if ( aKeyboardState.IsKeyDown( Keys.Left ) ) then
    begin
    // Rotate Left
    steerRotationValue := steerRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    end
    else if ( aKeyboardState.IsKeyDown( Keys.Right ) ) then
    begin
    // Rotate Right
    steerRotationValue := steerRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    end;

    // Restrict how much we can steer the wheels
    steerRotationValue := MathHelper.Clamp( steerRotationValue, -0.8, 0.8 );

    // Change our TankRotation
    tankRotation := tankRotation - steerRotationValue * 0.10;

    if ( aKeyboardState.IsKeyDown( Keys.Up ) ) then
    begin
    //create some velocity if the up key is pressed
    tankVelocityAdd := Vector3.Zero;

    //find out what direction we should be thrusting, using rotation
    tankVelocityAdd.X := -Math.Sin( tankRotation );
    tankVelocityAdd.Z := -Math.Cos( tankRotation );

    // scale velocity
    tankVelocityAdd := tankVelocityAdd / ( lTimeMilliSeconds * MathHelper.ToRadians( 0.5 ) );

    // Move Forward
    tankVelocity := tankVelocity + tankVelocityAdd;
    end
    else if ( aKeyboardState.IsKeyDown( Keys.Down ) ) then
    begin
    //reduce our velocity if the down key is pressed
    tankVelocityAdd := Vector3.Zero;

    //find out what direction we should be thrusting, using rotation
    tankVelocityAdd.X := -Math.Sin( tankRotation );
    tankVelocityAdd.Z := -Math.Cos( tankRotation );

    // scale velocity
    tankVelocityAdd := tankVelocityAdd / ( lTimeMilliSeconds * MathHelper.ToRadians( 0.5 ) );

    // Move Forward
    tankVelocity := tankVelocity - tankVelocityAdd;
    end;

    if ( aKeyboardState.IsKeyDown( Keys.H ) ) then
    begin
    openHatch := not openHatch;
    end;
    end;
    {$ENDREGION}

    {$REGION Mouse}
    if Assigned( aMouseState ) then
    begin
    currentMouseX := aMouseState.X;
    currentMouseY := aMouseState.Y;
    if ( previousMouseX <currentMouseX> previousMouseX ) then
    turretRotationValue := turretRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    turretRotationValue := turretRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    previousMouseX := currentMouseX;
    end;

    if ( previousMouseY <currentMouseY> previousMouseY ) then
    cannonElevationValue := cannonElevationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    cannonElevationValue := cannonElevationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );

    // Restrict how much we can raise and lower the cannon
    cannonElevationValue := MathHelper.Clamp( cannonElevationValue, -1.4, 0.2 );
    previousMouseY := currentMouseY;
    end;
    end;
    {$ENDREGION}

    wheelRotationValue := tankVelocity.Z;

    if openHatch then
    hatchRotationValue := hatchRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    hatchRotationValue := hatchRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );

    // Limit how wide we open
    hatchRotationValue := MathHelper.Clamp( hatchRotationValue, -1, 0 );

    //add velocity to current position
    tankPosition := tankPosition + tankVelocity;

    //bleed off velocity over time
    tankVelocity := tankVelocity * 0.95;
    end;
    [/pascal]
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #43

    Pascal and XNA...

    Quote Originally Posted by savage
    [pascal]
    method TTank.UpdateInput( aGameTime : Gametime; aGamePadState : GamePadState; aKeyboardState : KeyboardState; aMouseState : MouseState ) : boolean;
    var
    tankVelocityAdd : Vector3;
    lTimeSeconds : single;
    lTimeMilliSeconds : single;
    lVelocity: single;
    begin
    result := true;
    lTimeMilliSeconds := aGameTime.ElapsedGameTime.TotalMilliseconds;
    lTimeSeconds := aGameTime.TotalGameTime.TotalSeconds;

    {$REGION GamePad}
    if ( aGamePadState.IsConnected ) then
    begin
    // Allows the default game to exit on Xbox 360 and Windows using a Gamepad
    if ( aGamePadState.Buttons.Back = ButtonState.Pressed ) then
    begin
    result := false;
    Exit;
    end;

    //rotate the model using the left thumbstick, scale it down
    tankRotation := tankRotation - aGamePadState.ThumbSticks.Left.X * 0.10;

    //create some velocity if the right trigger is down
    tankVelocityAdd := Vector3.Zero;

    //find out what direction we should be thrusting, using rotation
    tankVelocityAdd.X := -Math.Sin( tankRotation );
    tankVelocityAdd.Z := -Math.Cos( tankRotation );

    //now scale our direction by how hard the trigger is down
    tankVelocityAdd := tankVelocityAdd * aGamePadState.Triggers.Right;

    //finally, add this vector to our velocity.
    tankVelocity := tankVelocity + tankVelocityAdd;

    GamePad.SetVibration( PlayerIndex.One, aGamePadState.Triggers.Right, aGamePadState.Triggers.Right );

    //in case you get lost, press A to warp back to the center
    if ( aGamePadState.Buttons.A = ButtonState.Pressed ) then
    begin
    tankPosition := Vector3.Zero;
    tankVelocity := Vector3.Zero;
    tankRotation := 0.0;
    end;
    end;
    {$ENDREGION}

    {$REGION Keyboard}
    if Assigned( aKeyboardState ) then
    begin
    // Allows the default game to exit on Xbox 360 and Windows using a Keyboard
    if ( aKeyboardState.IsKeyDown( Keys.Escape ) ) then
    begin
    result := false;
    Exit;
    end;

    //in case you get lost, press Spacebar to warp back to the center
    if ( aKeyboardState.IsKeyDown( Keys.Space ) ) then
    begin
    //Key has just been pressed
    tankPosition := Vector3.Zero;
    tankVelocity := Vector3.Zero;
    tankRotation := 0.0;
    end;
    // otherwise, check to see we are moving left, right forward backward
    // (and therefore just released)
    if ( aKeyboardState.IsKeyDown( Keys.Left ) ) then
    begin
    // Rotate Left
    steerRotationValue := steerRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    end
    else if ( aKeyboardState.IsKeyDown( Keys.Right ) ) then
    begin
    // Rotate Right
    steerRotationValue := steerRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    end;

    // Restrict how much we can steer the wheels
    steerRotationValue := MathHelper.Clamp( steerRotationValue, -0.8, 0.8 );

    if ( aKeyboardState.IsKeyDown( Keys.Up ) ) then
    begin
    lVelocity := 1;
    end
    else if ( aKeyboardState.IsKeyDown( Keys.Down ) ) then
    begin
    lVelocity := -1;
    end;

    tankVelocityAdd := Vector3.Zero;
    tankVelocityAdd.X := Math.Sin(steerRotationValue+tankRotation)*lVelocit y;
    tankVelocityAdd.Z := Math.Cos(steerRotationValue+tankRotation)*lVelocit y;

    tankVelocity := Vector3.Dot(Vector3.Normalize(tankVelocity), Vector3.Normalize(tankVelocityAdd))*tankVelocity;

    tankVelocity := (tankVelocity+tankVelocityAdd) / ( lTimeMilliSeconds * MathHelper.ToRadians( 0.5 ) );

    // Change our TankRotation
    tankRotation := tankRotation - sin(steerRotationValue) * Vector3.Length(tankVelocity) / ( lTimeMilliSeconds * MathHelper.ToRadians( 0.5 ) );

    if ( aKeyboardState.IsKeyDown( Keys.H ) ) then
    begin
    openHatch := not openHatch;
    end;
    end;
    {$ENDREGION}

    {$REGION Mouse}
    if Assigned( aMouseState ) then
    begin
    currentMouseX := aMouseState.X;
    currentMouseY := aMouseState.Y;
    if ( previousMouseX <currentMouseX> previousMouseX ) then
    turretRotationValue := turretRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    turretRotationValue := turretRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );
    previousMouseX := currentMouseX;
    end;

    if ( previousMouseY <currentMouseY> previousMouseY ) then
    cannonElevationValue := cannonElevationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    cannonElevationValue := cannonElevationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );

    // Restrict how much we can raise and lower the cannon
    cannonElevationValue := MathHelper.Clamp( cannonElevationValue, -1.4, 0.2 );
    previousMouseY := currentMouseY;
    end;
    end;
    {$ENDREGION}

    wheelRotationValue := tankVelocity.Z;

    if openHatch then
    hatchRotationValue := hatchRotationValue - ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) )
    else
    hatchRotationValue := hatchRotationValue + ( lTimeMilliSeconds * MathHelper.ToRadians( 0.1 ) );

    // Limit how wide we open
    hatchRotationValue := MathHelper.Clamp( hatchRotationValue, -1, 0 );

    //add velocity to current position
    tankPosition := tankPosition + tankVelocity;

    //bleed off velocity over time
    tankVelocity := tankVelocity * 0.95;
    end;
    [/pascal]
    I just altered it quite a bit. This may work or it may not. I was only awake while I rewrote half of it
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  4. #44

    Pascal and XNA...

    Thanks JSoftware, I'll try it on my work machine on Monday.

    My book should arrive this week, so hopefully I won't bother you guys so much with this 3D stuff.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #45

    Pascal and XNA...

    More XNA Samples have been posted on the creators site - http://creators.xna.com/Education/Samples.aspx as well as a full 3D Racing Car game available as a Starter Kit from http://creators.xna.com/Education/StarterKits.aspx
    The racing game looks quite professional and comes with full source code.

    There's less and less excuse not to use XNA now with Chrome.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #46
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Pascal and XNA...

    I'm thinking XNA Starters Kit Translation project.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  7. #47

    Pascal and XNA...

    Here's a screen shot of the racing game in action...

    [ Click to see a bigger picture ]

    It runs at 90 FPS on my machine at 1024 * 768 with all the effects on. I've read it runs equally well on the XBox 360.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #48
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Pascal and XNA...

    Wow thats pretty cool. What are your system specs so we can compare?

    As I alluded to before, someone should really consider a translation of this game's source to Object Pascal for Chrome. Or if not that create a game of their own that would look as or almost as good as this.

    How compatible is Chrome with XNA right now?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #49

    Pascal and XNA...

    Chrome as a compiler is 100% compatible with XNA. It you don't mind waiting for full XNA support in Visual 2005 ( NOT Express ), then you can start writing XNA code yesterday. The only issue is getting it only the XBox 360, but even that has a small work around until the support is built into VS2005.

    I also think it would be nice to port this demo to Chrome, but I don't have the time right now to start another port project.

    My system specs are the ones I posted when I bought the new motherboard, CPU and graphics card. The main thing is having Shader 2.0 or 3.0 support for most XNA stuff.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  10. #50
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Pascal and XNA...

    Oh ok. I'd be a bit left behind with my 1.2 Shader I think.

    What about the Command Line Edition of Chrome though? [size=9px](It's FREE btw everyone! )[/size]

    Are there things about XNA that would prevent someone from creating stuff made using that? I think in the worst case scenario one could make an IDE that took advantage of the command line compiler, much like how Lazarus does, but with whatever is required to get XNA games on the go. And who knows eventually XBox360 games too.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 5 of 7 FirstFirst ... 34567 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •