Author Topic: Quake - Zombies  (Read 2817 times)

unseenmachine

  • Hero Member
  • *****
  • Posts: 3663
  • Make the Game not the ENGINE!!!
Quake - Zombies
« on: November 10, 2012, 06:49:58 am »
Well, as everyone else is posting demo's screenshots of there upcoming projects i thought i would share mine. All i've done so far is intialisation, first person camera and terrain but it's a start.

https://dl.dropbox.com/u/8822351/Quake_Zombies_1.PNG

The basic idea for the game is...You play a marine who has been left behind supposed dead. When you awake, around you are many zombies and other damned creatures all baying for your blood. You have to fight your way through to checkpoints where you'll get intel, weapons and other stuff to help you reunite with your command unit.

Well back to coding...

Unseen

OlDosLover

  • Moderator
  • Hero Member
  • *****
  • Posts: 5320
  • OlDosLover
Re: Quake - Zombies
« Reply #1 on: November 11, 2012, 01:54:08 am »
Hi all,
    Nice terrain unseenmachine. Will be nice to see the zombies and weapons to get a better idea. Looks like this is gonna be a first for QB64.
OlDosLover.

unseenmachine

  • Hero Member
  • *****
  • Posts: 3663
  • Make the Game not the ENGINE!!!
Re: Quake - Zombies
« Reply #2 on: November 11, 2012, 02:30:59 am »
Thanks ODL. Zombie models are loaded but not yet rendered as i have to create spawn points and do terrain based collision detection to stop the zombies falling through the floor.

Program speed was an issue so i thought i'd try the old Wolfenstein trick and reduce the size of the screen. It worked a treat and now you can change the screen size to whatever suits your pc's abilities.

https://dl.dropbox.com/u/8822351/Quake_Zombies_2.PNG

Unseen

unseenmachine

  • Hero Member
  • *****
  • Posts: 3663
  • Make the Game not the ENGINE!!!
Re: Quake - Zombies
« Reply #3 on: November 11, 2012, 03:37:46 pm »
Now with weapons as requested.

https://dl.dropbox.com/u/8822351/Quake_Zombies_3.PNG

Unseen

And here's the source for anyone whos interested....

Code: [Select]
'// Quake - ZOMBIES!!!
'// By John Onyon a.k.a Unseen Machine

REM $INCLUDE:'GL_Consts.bas'

'// Set main root path for files
CHDIR "C:\QB64\My Games\Quake - ZOMBIES!!!!\"

'// try to create a OpenGL window
IF Init(800, 600, "Quake - ZOMBIES!!!") THEN

   '// Define global constants
   CONST False = 0, True = NOT False

   '// Define debug handler
   DIM Debug AS INTEGER

   '// Enable / disable debuging mode
   Debug = True
   'Debug = False

   '// If not in debug mode then hide the QB64 screen
   IF NOT Debug THEN _SCREENHIDE

   '// Define input handlers
   DIM KB(1) AS KEYBOARDSTATE, Mouse(1) AS MOUSESTATE

   '// Define Gamestate constants
   CONST Intialising = 0, MainMenu = 1, InGame = 2, Paused = 3, InGameMenu = 4

   '// Define gamestate handler
   DIM GameState AS INTEGER

   '// Define Camera variables
   DIM CamPos AS VECTOR

   '// Initial camera (Player position) settings
   CamPos.X = 380
   CamPos.Y = -80
   CamPos.Z = -230
   CamPos.XRot = 0
   CamPos.YRot = 0
   CamPos.ZRot = 0

   '// Define a variable to assist in movement calculations
   RadHelp# = (4 * ATN(1)) / 180

   '// MAIN LOOP >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   DO

      '// Set maximum loops per second limit
      _LIMIT 30

      '// Update global timer
      GlobalTime# = TIMER(.001)

      '// Main gamestate case handler
      SELECT CASE GameState

         CASE Intialising

            IF Debug THEN PRINT "Starting..."

            '// Define model arrays
            DIM MDL_CLRS(255) AS LONG, MDL_NORMALS(162) AS VertexF
            GDK_GL_MDL_LOAD_COLORS MDL_CLRS()
            GDK_GL_MDL_LOAD_NORMALS MDL_NORMALS()

            DIM Zombie AS MDL_header
            DIM Shotgun AS MDL_header

            '// Load models
            IF Debug THEN PRINT "Loading Zombie model...";
            ZombieModel% = GDK_GL_MDL_NEW("Resources\Models\Characters\Zombie.mdl", Zombie)
            IF ZombieModel% THEN
               DIM ZombieSkin(Zombie.num_skins - 1) AS MDL_skin
               DIM ZombieSkinImage(Zombie.num_skins - 1) AS LONG
               DIM ZombieTexCoord(Zombie.num_verts - 1) AS MDL_texcoord
               DIM ZombieTris(Zombie.num_tris - 1) AS MDL_triangle
               DIM ZombieFrames(Zombie.num_frames - 1) AS MDL_frame
               DIM ZombieVerts(Zombie.num_frames - 1, Zombie.num_verts - 1) AS MDL_vertex
               GDK_GL_MDL_LOAD "Resources\Models\Characters\Zombie.mdl", Zombie, ZombieSkin(), ZombieSkinImage(), MDL_CLRS(), ZombieTexCoord(), ZombieTris(), ZombieFrames(), ZombieVerts()
               ZombieSkin& = GDK_GL_MAKE_TEXTURE(ZombieSkinImage(0))
               IF Debug THEN PRINT "Success."
            ELSE
               IF Debug THEN PRINT "Failed."
               END
            END IF

            IF Debug THEN PRINT "Loading Shotgun model...";
            ShotgunModel% = GDK_GL_MDL_NEW("Resources\Models\Weapons\Shotgun.mdl", Shotgun)
            IF ShotgunModel% THEN
               DIM ShotgunSkin(Shotgun.num_skins - 1) AS MDL_skin
               DIM ShotgunSkinImage(Shotgun.num_skins - 1) AS LONG
               DIM ShotgunTexCoord(Shotgun.num_verts - 1) AS MDL_texcoord
               DIM ShotgunTris(Shotgun.num_tris - 1) AS MDL_triangle
               DIM ShotgunFrames(Shotgun.num_frames - 1) AS MDL_frame
               DIM ShotgunVerts(Shotgun.num_frames - 1, Shotgun.num_verts - 1) AS MDL_vertex
               GDK_GL_MDL_LOAD "Resources\Models\Weapons\Shotgun.mdl", Shotgun, ShotgunSkin(), ShotgunSkinImage(), MDL_CLRS(), ShotgunTexCoord(), ShotgunTris(), ShotgunFrames(), ShotgunVerts()
               ShotgunSkin& = GDK_GL_MAKE_TEXTURE(ShotgunSkinImage(0))
               IF Debug THEN PRINT "Success."
            ELSE
               IF Debug THEN PRINT "Failed."
               END
            END IF



            '// Set animations

            DIM ZombieAnim(3) AS ANIMATION
            DIM ShotgunAnim(3) AS ANIMATION


            '// Define terrain arrays
            REDIM LevelVert(0, 0) AS VertexF
            DIM LevelTexture AS _UNSIGNED LONG

            '// Load terrain
            GDK_GL_MAP_LOAD "Resources\Levels\HillsHeightMap.png", LevelVert(), 6, LevelH&, LevelW&, .45
            LevelTexture = GDK_GL_LOAD_TEXTURE("Resources\Levels\Hills.png")

            '// Generate terrain list for faster rendering
            Terrain& = glGenLists(1)
            glNewList Terrain&, GL_COMPILE
            glPushMatrix
            GDK_GL_SET_TEXTURE LevelTexture
            GDK_GL_MAP_DRAW -768, -80, -768, LevelVert(), LevelH&, LevelW&, _WIDTH(LevelTexture), _HEIGHT(LevelTexture)
            glPopMatrix
            glEndList

            '// Define and load sky sphere texture
            DIM Sky AS LONG
            Sky = GDK_GL_LOAD_TEXTURE("Resources\Levels\Sky.png")

            '// Create sky sphere list
            SkySphere& = glGenLists(2)
            glNewList SkySphere&, GL_COMPILE
            GDK_GL_SET_TEXTURE Sky
            glPushMatrix
            glRotatef 90, 1, 0, 0
            GDK_GL_SPHERE 600, 15, 15, -1
            glPopMatrix
            glEndList

            '// Create sphere/terrain combined list
            World& = glGenLists(3)
            glNewList World&, GL_COMPILE
            glCallList SkySphere&
            glCallList Terrain&
            glEndList

            '// Switch game state
            GameState = MainMenu

         CASE MainMenu

            IF Debug THEN PRINT "Entering Main Menu..."


            '// Center the mouse
            GDK_GL_MOUSE_MOVE GDK_GL_SCREEN_WIDTH(0) / 2, GDK_GL_SCREEN_HEIGHT(0) / 2, 0

            '// Switch game state
            GameState = InGame

         CASE InGame

            '// Get the state of the input devices
            GDK_GL_KEYBOARD_GET_STATE KB(0), 0
            GDK_GL_MOUSE_GET_STATE Mouse(0), 0

            '// Window resize
            ResizeWindow

            '// 1st person camera
            NewCamXRot% = CamPos.XRot + (Mouse(0).Y - Mouse(1).Y)
            IF NewCamXRot% > -25 AND NewCamXRot% < 25 THEN CamPos.XRot = NewCamXRot%

            CamPos.YRot = CamPos.YRot + (Mouse(0).X - Mouse(1).X)
            IF CamPos.YRot > 360 THEN CamPos.YRot = CamPos.YRot - 360

            IF KB(0).A THEN
               StrafeY# = (CamPos.YRot + 90) * RadHelp#
               StrafeX# = (CamPos.XRot + 90) * RadHelp#
               NewCamXPos = CamPos.X + (SIN(StrafeY#) * 8)
               IF NewCamXPos > -400 AND NewCamXPos < 400 THEN CamPos.X = NewCamXPos
               NewCamZpos = CamPos.Z - (COS(StrafeY#) * 8)
               IF NewCamZpos > -400 AND NewCamZpos < 400 THEN CamPos.Z = NewCamZpos
            ELSEIF KB(0).D THEN
               StrafeY# = (CamPos.YRot + 90) * RadHelp#
               StrafeX# = (CamPos.XRot + 90) * RadHelp#
               NewCamXPos = CamPos.X - (SIN(StrafeY#) * 8)
               IF NewCamXPos > -400 AND NewCamXPos < 400 THEN CamPos.X = NewCamXPos
               NewCamZpos = CamPos.Z + (COS(StrafeY#) * 8)
               IF NewCamZpos > -400 AND NewCamZpos < 400 THEN CamPos.Z = NewCamZpos
            END IF
            IF KB(0).W THEN
               YSin# = SIN(CamPos.YRot * RadHelp#) * 8
               YCos# = COS(CamPos.YRot * RadHelp#) * 8
               NewCamXPos = CamPos.X - YSin#
               IF NewCamXPos > -400 AND NewCamXPos < 400 THEN CamPos.X = NewCamXPos
               NewCamZpos = CamPos.Z + YCos#
               IF NewCamZpos > -400 AND NewCamZpos < 400 THEN CamPos.Z = NewCamZpos
            ELSEIF KB(0).S THEN
               YSin# = SIN(CamPos.YRot * RadHelp#) * 8
               YCos# = COS(CamPos.YRot * RadHelp#) * 8
               NewCamXPos = CamPos.X + YSin#
               IF NewCamXPos > -400 AND NewCamXPos < 400 THEN CamPos.X = NewCamXPos
               NewCamZpos = CamPos.Z - YCos#
               IF NewCamZpos > -400 AND NewCamZpos < 400 THEN CamPos.Z = NewCamZpos
            END IF


            IF Debug THEN
               CLS
               PRINT "Camera"
               PRINT "X : " + STR$(CamPos.X)
               PRINT "Y : " + STR$(CamPos.Y)
               PRINT "Z : " + STR$(CamPos.Z)
               PRINT "XRot : " + STR$(CamPos.XRot)
               PRINT "YRot : " + STR$(CamPos.YRot)
               PRINT "ZRot : " + STR$(CamPos.ZRot)
            END IF

            '// Clear the Opengl screen / Reset the depth buffer
            glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT

            '// Reset the view
            glLoadIdentity

            glPushMatrix
            glRotatef 90, 0, 1, 0
            glRotatef 270, 1, 0, 0
            glTranslatef 10, 0, 0
            GDK_GL_SET_TEXTURE ShotgunSkin&
            GDK_GL_MDL_DRAW Shotgun, 0, ShotgunSkin&, ShotgunTexCoord(), ShotgunTris(), ShotgunVerts(), MDL_NORMALS()
            glPopMatrix

            '// Move to the camera view
            glRotatef CamPos.XRot, 1, 0, 0
            glRotatef CamPos.YRot, 0, 1, 0
            glRotatef CamPos.ZRot, 0, 0, 1
            glTranslatef CamPos.X, CamPos.Y, CamPos.Z

            '// Draw models, terrain and anything else
            glCallList World&


            '// Update the OpenGL screen
            GDK_GL_SCREEN_DISPLAY 0

            '// Copy the input handlers
            KB(1) = KB(0)
            Mouse(1) = Mouse(0)

         CASE Paused

         CASE InGameMenu

      END SELECT

      '// If in debug mode then update the QB64 window
      IF Debug THEN _DISPLAY

      '// If the player presses the red x then exit the program
      IF GDK_GL_SCREEN_EXIT(0) THEN SYSTEM

   LOOP
   '// END OF MAIN LOOP >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


ELSE
   '// Failed to create a OpenGL window
   PRINT "ERROR COULD NOT CREATE RENDERING ENVIROMENT!!!!"
   END
END IF



REM $INCLUDE:'UnseenGDK_GL.bm'

FUNCTION Init (Width%, Height%, Title$)
Screen1% = GDK_GL_SCREEN(Width%, Height%, Title$, 0) '// Create a screen
IF Screen1% THEN
   GDK_GL_SCREEN_SET_FPS 30, 0 '    // Set maximium frames per second
   glClearColor 0.0, 0.0, 0.0, 1.0 '// Set background (clear) color to black
   glClearDepth 1 '                 // Set clear depth value to farthest
   glEnable GL_DEPTH_TEST '         // Enables depth buffer for hidden surface removal
   glEnable GL_TEXTURE_2D '         // Enable texturing
   glEnable GL_CULL_FACE
   glFrontFace GL_CW
   glHint GL_LINE_SMOOTH_HINT, GL_FASTEST
   glHint GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST
   glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST
   glShadeModel GL_FLAT
   glMatrixMode GL_PROJECTION
   AspectRatio! = GDK_GL_SCREEN_WIDTH(0) / GDK_GL_SCREEN_HEIGHT(0)
   gluPerspective 45, AspectRatio!, 1, 1200
   glMatrixMode GL_MODELVIEW
   glLoadIdentity
   SCREEN _NEWIMAGE(400, 768, 32)
   Init = -1
ELSE
   Init = 0
END IF
END FUNCTION



SUB GDK_GL_MAP_DRAW (X!, Y!, Z!, MapVert() AS VertexF, ImgH&, ImgW&, TextW&, TextH&)
glTranslatef X!, Y!, Z!
TYInc! = 1 / ImgH&
TXInc! = 1 / ImgW&
FOR j& = 0 TO ImgH& - 1
   glBegin GL_TRIANGLE_STRIP
   Tx! = 0
   Ty! = Ty! + TYInc!
   FOR i& = 0 TO ImgW& - 1
      Tx! = Tx! + TXInc!
      glTexCoord2f LastX!, LastY!
      glVertex3f MapVert(i&, j&).X, MapVert(i&, j&).Y, MapVert(i&, j&).Z
      glTexCoord2f Tx!, LastY!
      glVertex3f MapVert(i& + 1, j&).X, MapVert(i& + 1, j&).Y, MapVert(i& + 1, j&).Z
      glTexCoord2f LastX!, Ty!
      glVertex3f MapVert(i&, j& + 1).X, MapVert(i&, j& + 1).Y, MapVert(i&, j& + 1).Z
      glTexCoord2f Tx!, Ty!
      glVertex3f MapVert(i& + 1, j& + 1).X, MapVert(i& + 1, j& + 1).Y, MapVert(i& + 1, j& + 1).Z
      LastX! = Tx!
   NEXT
   LastY! = Ty!
   glEnd
NEXT
END SUB



SUB GDK_GL_MAP_LOAD (FileName$, MapVertArray() AS VertexF, Scale!, GetH&, GetW&, HeightScale!)
MapImage& = _LOADIMAGE(FileName$, 32)
W& = _WIDTH(MapImage&) - 1
H& = _HEIGHT(MapImage&) - 1
GetH& = H&
GetW& = W&
REDIM MapVertArray(W&, H&) AS VertexF
_SOURCE MapImage&
FOR j& = 0 TO H&
   FOR i& = 0 TO W&
      M& = POINT(i&, j&)
      clrsum% = (INT((_BLUE(M&) / 100) * 11) + INT((_RED(M&) / 100) * 39) + INT((_GREEN(M&) / 100) * 50))
      MapVertArray(i&, j&).X = i& * Scale!
      MapVertArray(i&, j&).Y = clrsum% * HeightScale!
      MapVertArray(i&, j&).Z = j& * Scale!
   NEXT
NEXT
_SOURCE 0
_FREEIMAGE MapImage&
END SUB


SUB ResizeWindow
glViewport 0, 0, GDK_GL_SCREEN_WIDTH(0), GDK_GL_SCREEN_HEIGHT(0)
END SUB

Unseen

OlDosLover

  • Moderator
  • Hero Member
  • *****
  • Posts: 5320
  • OlDosLover
Re: Quake - Zombies
« Reply #4 on: November 11, 2012, 07:35:10 pm »
Hi all,
    wow what sorta bullet is that? Loved the gun also. Hmm thanks for the source.
OlDosLover.


FALCON

  • Full Member
  • ***
  • Posts: 163
  • Linux Mint
Re: Quake - Zombies
« Reply #5 on: November 14, 2012, 04:42:40 pm »
Wow, that is looking good.

barbarian.1987

  • Jr. Member
  • **
  • Posts: 86
    • barbarian site
Re: Quake - Zombies
« Reply #6 on: November 15, 2012, 05:46:42 am »
thanks for the source
can you give some ressources, for launch the exe...
thanks in advance
F.L

unseenmachine

  • Hero Member
  • *****
  • Posts: 3663
  • Make the Game not the ENGINE!!!
Re: Quake - Zombies
« Reply #7 on: December 22, 2012, 07:30:18 pm »
Sorry guys its gonna be a while till i am back online for proper so bear with me. This is s project i will get a good way to finished so i will be needing  some help along the way. As soon as i get my pc back online (at a friends house at the moment) i will post a link to what i've got so far. The first thing i'll be needing help with is using vertex buffer objects in qb64 to increase the speed of drawing the terrain but i've got a few other tricks to make that faster to. i've not yet ported the relevant GL commands to GDK_GL but i've done the research on the commands and it should be quite straight forward. The next thing after that is calculating the height if the vertex the player is on the make it so you walk at the same height of the terrain. Then comes the fun parts and also where i expect my old coding buddies darth and CG where come to my rescue as maths is not my strongest skill, par ray casting part collision detection math but thats a way of and partly covered in an old thread i made when i was updating GDK's capabilities.

Hope to speak to you all again soon.

Unseen

OlDosLover

  • Moderator
  • Hero Member
  • *****
  • Posts: 5320
  • OlDosLover
Re: Quake - Zombies
« Reply #8 on: December 22, 2012, 07:50:49 pm »
Hi all,
    Thanks for the update unseen. Hope your circumstances improve. I gather you will release the updated GDK's also.
OlDosLover.

Pete

  • Hero Member
  • *****
  • Posts: 7249
  • Cuz I sez so varmint!
Re: Quake - Zombies
« Reply #9 on: December 22, 2012, 08:34:44 pm »
Screen shots look promising.

Pete
Give a man a program, and he does one thing for a day. Teach a man to program, and he does one thing for a lifetime.

Clippy

  • Hero Member
  • *****
  • Posts: 19336
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Quake - Zombies
« Reply #10 on: December 22, 2012, 10:22:59 pm »
I recently bought the old Doom games for my XBOX. It is great to go back and do it all over again.

Or is that thinking too much like a Republican...  ;)
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

unseenmachine

  • Hero Member
  • *****
  • Posts: 3663
  • Make the Game not the ENGINE!!!
Re: Quake - Zombies
« Reply #11 on: December 22, 2012, 10:28:41 pm »
I will release the updated GDK_GL lib once i get back online. Once galleon makes Qb64 GL able to use GL i'll only be using that if i can get my head round it's constraints.

Pete, any praise from you is like praise from god himself afterall you and clippy were the ones who taught me in the first place.

Unseen