Results 1 to 10 of 103

Thread: PGDmC: Vectored!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by pstudio View Post
    looks good but that's a pretty low frame rate you've got there.
    That is due to the video capturing - it drops the frame rate quite a bit! mutter...mutter...

    The actual game frame rate is higher; ~ 50 to 60 FPS

    cheers,
    Paul

  2. #2
    Here is a new screenshot - I am firing triple-shot blasts at asteroids



    With one button, I can fire normal blasts (1, 2, or 3 shot blasts - does 1, 2, or 3 hits of damage), or a missile blast (does lots of damage!)

    It depends on the time the fire button is held down as to whether a normal blast, or missile is shot - keeps the button count down for the competition!

    I can destroy asteroids, but not much else is happening yet; no explosions and other effects (or enemies)...I will get there LOL

    cheers,
    Paul

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Lookin' good. Trying to make the ship more visible with thicker lines are ya?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4
    Quote Originally Posted by WILL View Post
    Lookin' good. Trying to make the ship more visible with thicker lines are ya?
    LOL yeah...all the objects in the game are now drawn using my shiny new glowing line routine that I got working a couple of days ago. I am very pleased with the results.

    It uses a triangle strip to draw parts of an alpha blended circle texture as a line replacement:



    cheers,
    Paul

  5. #5
    Quote Originally Posted by paul_nicholls View Post
    LOL yeah...all the objects in the game are now drawn using my shiny new glowing line routine that I got working a couple of days ago. I am very pleased with the results.

    It uses a triangle strip to draw parts of an alpha blended circle texture as a line replacement:
    That's a very nice pseudo-filter! It looks as good as a real one! (And as a bonus I am sure it is less messy to get different glow at different parts.)

  6. #6
    Quote Originally Posted by Ingemar View Post
    That's a very nice pseudo-filter! It looks as good as a real one! (And as a bonus I am sure it is less messy to get different glow at different parts.)
    Thanks mate

    If you are interested, here is the code I wrote. It uses Jarrod Davis' SvEngine and its OpenGL like primitives routines (I also wrote those) so it could easily be adapted to OpenGL or some other system

    If you examine the code, I have included 'diagrams' of where all the points are and how they are used for the triangle strips.

    Note: if converting to straight OpenGL, you need to do anti-clockwise vertices as opposed to clockwise in DirectX (SvEngine uses DirectX behind the scenes)! Same with the texture coordinates, the v coord (vertical ones are flipped around in OpenGL I believe)...

    Oh, and here is the glow texture I used too (very very hard to see as it is very alpha blended) - I have surrounded it by another colour so you can see it:
    particle3_colorkey.png

    Code:
    unit unit_glowinglines;
    
    interface
    
    uses
      SvEngine;
    
    procedure DrawGlowingLine(x1,y1,x2,y2: Single; color: cardinal; RenderState: Integer; texture: TsvTexture; DrawEnd1,DrawEnd2: Boolean; width: Single = 1);
    
    implementation
    
    uses
      unit_vectors;
    
    type
    //
    // TRGBA
    //
      TRGBA = packed record
        case Integer of
          0: (b,g,r,a: Byte);
          1: (Value: Cardinal);
      end;
    
    //
    // glowing line routines
    //
    
    function  OffsetCoord(const ox,oy,x,y: Single; up,right: TVector2f): TVector2f;
    // this function moves along the rotated space's up & right vectors by
    // y and x respectively, and then translates it to ox,oy
    begin
      Result.x := ox + x * right.x + y * up.x;
      Result.y := oy + x * right.y + y * up.y;
    end;
    
    procedure DrawGlowingLine(x1,y1,x2,y2: Single; color: cardinal; RenderState: Integer; texture: TsvTexture; DrawEnd1,DrawEnd2: Boolean; width: Single = 1);
    var
      up, right: TVector2f;
      dx,dy: Single;
      radius: Single;
      p0,p1,p2,p3: TVector2f;
      p4,p5,p6,p7: TVector2f;
      c: TRGBA;
    begin
      c.Value := color;
    
      if width <= 1 then
      begin
        sv.RenderDevice.BeginPrimitive(ptLineList,RenderState,nil);
          sv.RenderDevice.Color4ub(c.r,c.g,c.b,c.a);
          sv.RenderDevice.Vertex2f(x1,y1);
          sv.RenderDevice.Vertex2f(x2,y2);
        sv.RenderDevice.EndPrimitive;
    
        Exit;
      end;
    
      radius := width / 2;
    
      dx := X2 - X1;
      dy := Y2 - Y1;
    
      // calculate rotation vectors for line
      up    := VecNormalize(VecPerp(Vector2f(dx,dy)));
      right := VecNormalize(Vector2f(dx,dy));
    
      // calculate triangle strip points
      p1 := OffsetCoord(x1,y1,-radius,-radius,up,right);
      p7 := OffsetCoord(x2,y2,+radius,-radius,up,right);
      p6 := OffsetCoord(x2,y2,+radius,+radius,up,right);
      p0 := OffsetCoord(x1,y1,-radius,+radius,up,right);
    
      p5 := OffsetCoord(x2,y2,0,-radius,up,right);
      p4 := OffsetCoord(x2,y2,0,+radius,up,right);
      p2 := OffsetCoord(x1,y1,0,+radius,up,right);
      p3 := OffsetCoord(x1,y1,0,-radius,up,right);
    
    {
      U->   0.0      0.5                     0.5        1.0
    
            p1       p3                      p5         p7
      0.0   +--------*-----------------------*----------+     0.0
    V       |                   up                      |
    |       |      x1,y1         |         x2,y2        |
    v       |        *-----------+-----------*          |
            |                       right ->            |
            |                                           |
      0.1   +--------*-----------------------*----------+     1.0
            p0      p2                       p4         p6
    
      uv    0.0      0.5                     0.5        1.0
    }
    
      sv.RenderDevice.BeginPrimitive(ptTriangleStrip,RenderState,texture);
    
        sv.RenderDevice.Color4ub(c.r,c.g,c.b,c.a);
    
        {
        triangle strip vertex order
        ---------------------------
            1  3  5  7
            +--+--+--+
            |\ |\ |\ |
            | \| \| \|
            +--+--+--+
            0  2  4  6
        }
        if DrawEnd1 then
        begin
          sv.RenderDevice.Texcoord2f(0.0,1); sv.RenderDevice.Vertex2f(p0.x,p0.y);
          sv.RenderDevice.Texcoord2f(0.0,0); sv.RenderDevice.Vertex2f(p1.x,p1.y);
        end;
    
        // stretch center of texture along middle section
        sv.RenderDevice.Texcoord2f(0.5,1); sv.RenderDevice.Vertex2f(p2.x,p2.y);
        sv.RenderDevice.Texcoord2f(0.5,0); sv.RenderDevice.Vertex2f(p3.x,p3.y);
        sv.RenderDevice.Texcoord2f(0.5,1); sv.RenderDevice.Vertex2f(p4.x,p4.y);
        sv.RenderDevice.Texcoord2f(0.5,0); sv.RenderDevice.Vertex2f(p5.x,p5.y);
    
        if DrawEnd2 then
        begin
          sv.RenderDevice.Texcoord2f(1.0,1); sv.RenderDevice.Vertex2f(p6.x,p6.y);
          sv.RenderDevice.Texcoord2f(1.0,0); sv.RenderDevice.Vertex2f(p7.x,p7.y);
        end;
    
      sv.RenderDevice.EndPrimitive;
    end;
    
    end.
    unit_vectors.pas
    Code:
    unit unit_vectors;
    
    interface
    
    type
    //
    // TVector2f
    //
      PVector2f = ^TVector2f;
      TVector2f = record
        x, y: Single;
      end;
    
    //
    // TVector3f
    //
      PVector3f = ^TVector3f;
      TVector3f = record
        x, y, z: Single;
      end;
    
    //
    // TVector4f
    //
      PVector4f = ^TVector4f;
      TVector4f = array[0..3] of Single;
    
    function  Vector2f(const aX,aY: Single): TVector2f;
    function  VecNegative(const v: TVector2f): TVector2f; overload;
    function  VecAdd(const v1, v2: TVector2f): TVector2f; overload;
    function  VecSubtract(const v1, v2: TVector2f): TVector2f; overload;
    function  VecMultiply(const v: TVector2f; const s: Single): TVector2f; overload;
    function  VecNormalize(const v: TVector2f): TVector2f; overload;
    function  VecLen(const v: TVector2f): Single; overload;
    function  VecDot(const v1,v2: TVector2f): Single; overload;
    function  VecPerp(const v: TVector2f): TVector2f;
    
    function  Vector3f(const aX,aY,aZ: Single): TVector3f;
    function  VecNegative(const v: TVector3f): TVector3f; overload;
    function  VecAdd(const v1, v2: TVector3f): TVector3f; overload;
    function  VecSubtract(const v1, v2: TVector3f): TVector3f; overload;
    function  VecMultiply(const v: TVector3f; const s: Single): TVector3f; overload;
    function  VecNormalize(const v: TVector3f): TVector3f; overload;
    function  VecLen(const v: TVector3f): Single; overload;
    function  VecDot(const v1,v2: TVector3f): Single; overload;
    function  VecCross(const v1,v2: TVector3f): TVector3f;
    
    function  Vector4f(const aX,aY,aZ: Single; const aW: Single = 1): TVector4f;
    
    implementation
    
    //
    // TVector2f routines
    //
    function Vector2f(const aX, aY: Single): TVector2f;
    begin
      Result.x := aX;
      Result.y := aY;
    end;
    
    function  VecNegative(const v: TVector2f): TVector2f;
    begin
      Result.x := -v.x;
      Result.y := -v.y;
    end;
    
    function  VecAdd(const v1, v2: TVector2f): TVector2f;
    begin
      Result.x := v1.x + v2.x;
      Result.y := v1.y + v2.y;
    end;
    
    function  VecSubtract(const v1, v2: TVector2f): TVector2f;
    begin
      Result.x := v1.x - v2.x;
      Result.y := v1.y - v2.y;
    end;
    
    function  VecMultiply(const v: TVector2f; const s: Single): TVector2f;
    begin
      Result.x := v.x * s;
      Result.y := v.y * s;
    end;
    
    function  VecNormalize(const v: TVector2f): TVector2f;
    var
      mag: Single;
    begin
      mag := VecLen(v);
      if mag < 1 then mag := 1;
    
      Result.x := v.x / mag;
      Result.y := v.y / mag;
    end;
    
    function  VecLen(const v: TVector2f): Single;
    begin
      Result := Sqrt(Sqr(v.x) + Sqr(v.y));
    end;
    
    function  VecDot(const v1,v2: TVector2f): Single;
    begin
      Result := v1.x * v2.x + v1.y * v2.y;
    end;
    
    function  VecPerp(const v: TVector2f): TVector2f;
    begin
      Result := Vector2f(-v.y, v.x);
    end;
    
    //
    // TVector3f routines
    //
    function Vector3f(const aX, aY, aZ: Single): TVector3f;
    begin
      Result.x := aX;
      Result.y := aY;
      Result.z := aZ;
    end;
    
    function  VecNegative(const v: TVector3f): TVector3f;
    begin
      Result.x := -v.x;
      Result.y := -v.y;
      Result.z := -v.z;
    end;
    
    function  VecAdd(const v1, v2: TVector3f): TVector3f;
    begin
      Result.x := v1.x + v2.x;
      Result.y := v1.y + v2.y;
      Result.z := v1.z + v2.z;
    end;
    
    function  VecSubtract(const v1, v2: TVector3f): TVector3f;
    begin
      Result.x := v1.x - v2.x;
      Result.y := v1.y - v2.y;
      Result.z := v1.z - v2.z;
    end;
    
    function  VecMultiply(const v: TVector3f; const s: Single): TVector3f;
    begin
      Result.x := v.x * s;
      Result.y := v.y * s;
      Result.z := v.z * s;
    end;
    
    function  VecNormalize(const v: TVector3f): TVector3f;
    var
      mag: Single;
    begin
      mag := VecLen(v);
      if mag < 1 then mag := 1;
    
      Result.x := v.x / mag;
      Result.y := v.y / mag;
      Result.z := v.z / mag;
    end;
    
    function  VecLen(const v: TVector3f): Single;
    begin
      Result := Sqrt(Sqr(v.x) + Sqr(v.y) + Sqr(v.z));
    end;
    
    function  VecDot(const v1,v2: TVector3f): Single;
    begin
      Result := v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
    end;
    
    function  VecCross(const v1,v2: TVector3f): TVector3f;
    begin
      Result.x := v1.y * v2.z - v1.z * v2.y;
      Result.y := v1.z * v2.x - v1.x * v2.z;
      Result.z := v1.x * v2.y - v1.y * v2.x;
    end;
    
    //
    // TVector4f routines
    //
    function Vector4f(const aX, aY, aZ: Single; const aW: Single = 1): TVector4f;
    begin
      Result[0] := aX;
      Result[1] := aY;
      Result[2] := aZ;
      Result[3] := aW;
    end;
    
    end.
    cheers,
    Paul
    Last edited by paul_nicholls; 07-07-2011 at 10:48 PM.

  7. #7
    As a better FTP test for the competition, I have uploaded the current version of Vectored! to the FTP site so people can give it a whirl if they wish (Win32 only!!). You need 7z to unpack it (creates a folder, no install necessary).

    See the "paul_nicholls - vectored! - early test.7z" file (1.94 MB)

    NOTE: it is only a test at the moment, and nowhere near the final thing

    You can destroy asteroids and get destroyed by asteroids, but it has some sound effects now...yay (they were created using sfxr).

    It still needs optimizing to improve the frame rate at times

    Shoot = (quick tap for normal fire, hold down for 1 second or more to fire misslle)
    move left/right = left/right cursor keys
    Exit game = Escape

    Asteroids need 4 shots of normal fire to explode, but only 1 missile shot...

    cheers,
    Paul

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
  •