Game Engines???

Blitz3D Forums/Blitz3D Programming/Game Engines???

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Any projects you create with Blitz wiklk contain 'engines' by default as all games are programmed with the core elements. However, in making your 'engine' generic or accessable/"moddable" you will need to do a lot more work and include a lot more non-specific functinality.

For example, you may be coding a FPS style game with specific weapon types, though these weapons all utilise a basic cosde structure for firing:

(example pseuddocode)
Gun=GetCurrentGun()
Dir=GetDirectionFacing(X,Y,Z)
DoGunfire(Gun,XYZ)


In a specific code structured 'engine' for a single specific game, you may restrict DoGunfire, knowing that all your weapon will act in a certain way:

function DoGunfire(Gun, XYZ)

   if (Ammo(Gun)>0)

       Hit=Check 1stTarget(XYZ)
       if (Hit=ValidTarget())
          GetGunDamage(Gun)
           DoDamageToTarget(Hit)
       endif
       ReduceAmmo(Gun) 
       return
    else
       DoNoAmmoLeft()
    endif
    
    return
end function


In creating a more general and 'moddable' engine, you would need to consider all possible modification factors within the core code, so DoGunFire() would be more complex such as:

function DoGunfire(Gun, XYZ)

   if (Ammo(Gun)>0)
   
   select (GunType)

   case GUN_TYPE_BALLISTIC
       Hit=Check 1stTarget(XYZ)
       if (Hit=ValidTarget())
          GetGunDamage(Gun)
           DoDamageToTarget(Hit)
       endif
       ReduceAmmo(Gun) 
       return

   case GUN_TYPE_BEAM
       For CheckHits=1 to Range()
          Hit=GetTarget(XYZ,CheckHits)
          if (Hit=ValidTarget())
             GetGunDamage(Gun)
             DoDamageToTarget(Hit)
          endif
       Next
       ReduceAmmo(Gun) 
       return

   case GUN_TYPE_GRENADE
       Distance=GetDistanceFunction(XYZ)
       SetGrenadeTime(Gun,Millisecs)
       ThrowGrenade(Distance)   
       ReduceAmmo(Gun) 
       return
   end select

    else
       DoNoAmmoLeft()
    endif
    
    return
end function



Of course, that's only a suggested example. In reality, grenades would likely be handled separately altogether, but I hope you see my point. :)