Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


OandO

Member Since 11 Oct 2010
Offline Last Active Yesterday, 10:09 AM

#5205450 Funniest line of code ever ?

Posted by OandO on 19 January 2015 - 09:14 PM

typedef float flaot; // Quicker than learning to tpye accurately.



#5162448 Some times a little oversight can make a hilarious bug

Posted by OandO on 23 June 2014 - 07:44 PM

The first time I tried to do walking based on a (very much simplified) muscular system:




#5161851 Digital Trading Card Game / MMORPG Project

Posted by OandO on 20 June 2014 - 09:40 PM

The cards look fantastic, the map looks fantastic, the line art looks fantastic. Everything is tied together by a single visual theme... Why does the character art suddenly reject all that effort?




#5149756 gluLookAt() and matrix stack operations deprecated?

Posted by OandO on 26 April 2014 - 08:28 PM

Model space (or object space, to give it its usual name) positions in the buffer makes perfect sense. Consider the buffer to be the object in and of itself, and the vertex shader to be instructions for viewing it. Obviously that's a very simple version and the vertex shader can do a lot more, but it's a solid starting point.




#5114187 Multiple physics engines?

Posted by OandO on 03 December 2013 - 05:47 PM

When you crack absolutely perfect mechanics simulation with passable performance, do be sure to let the rest of us know how. wink.png




#5114132 Should I make my game engine cross platform?

Posted by OandO on 03 December 2013 - 02:54 PM

If making your engine cross-platform is causing you performance problems on your main platform (And you're not doing anything terribly advanced that's locked in to a particular set of drivers etc.) then you're doing something very wrong.

 

I would always say yes, but then I've never run into anything troublesome when supporting all three of those.




#5103752 The simplest of tasks...

Posted by OandO on 23 October 2013 - 09:59 AM

I now understand why games tend to take a very simplistic approach to reloading. I wanted to be clever, these two functions are a very roundabout way of incrementing one counter and decrementing another:

void updateWeaponLoadState(characterUnit_t *character)
{
int fireMode = 0; // FIXME - retrieve this from player structure
int loadType = character->weaponSlot[character->ps.weapon].loadType;
 
if (character->ps.magazineAmmo[character->ps.weapon] + character->ps.chamberedAmmo[character->ps.weapon] <= 0)
{ // No ammo, switch to empty state unless we're trying to reload
if (character->ps.weaponLoadState[character->ps.weapon] != RELOADSTATE_REMOVING_OLD_AMMO
&& character->ps.weaponLoadState[character->ps.weapon] != RELOADSTATE_ADDING_NEW_AMMO
&& character->ps.weaponLoadState[character->ps.weapon] != RELOADSTATE_OPENING
&& character->ps.weaponLoadState[character->ps.weapon] != RELOADSTATE_CLOSING)
{ // We not removing an empty mag or putting a new mag in at the moment, so set state to empty
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_EMPTY;
return;
}
}
 
if (character->weaponSlot[character->ps.weapon].shotsPerTrigger[fireMode] > 0)
{ // We're a single shot or burst weapon...
if (isWeaponManuallyCockedAfterShot(character) && character->ps.shotsRemaining == 0)
{ // ... that needs to be manually recocked after firing, and has finished firing
if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_COCKING && character->ps.weaponTime <= GameTime)
{ // We've completed the cocking sequence, go back to ready state
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_READY; // Set up to ready, and take a round from mag to chamber
character->ps.chamberedAmmo[character->ps.weapon]++; // FIXME - more/less than one round?
character->ps.magazineAmmo[character->ps.weapon]--;
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_FIRING)
{ // Weapon is not cocked, do it now.
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_COCKING;
// FIXME - cocking time could perhaps be affected by character stats.
character->ps.weaponTime = GameTime + character->weaponSlot[character->ps.weapon].cockingTime; 
}
}
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_FIRING && character->ps.weaponTime <= GameTime)
{ // An automatic or semi-automatic weapon that still has some ammo, and should be ready to fire again
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_READY;  // Set to ready, and take a round from mag to chamber
character->ps.chamberedAmmo[character->ps.weapon]++; // FIXME - more/less than one round?
character->ps.magazineAmmo[character->ps.weapon]--;
return;
}
 
if (character->ps.weaponState != WEAPONSTATE_RAISING &&
character->ps.weaponState != WEAPONSTATE_LOWERING &&
character->ps.weaponState != WEAPONSTATE_DROPPED)
{ // We're in a state where reloading is allowed
// Do these checks again, just in case something weird happened
if (character->ps.magazineAmmo[character->ps.weapon] >= character->weaponSlot[character->ps.weapon].magazineSize)
{ // Already a full mag, don't reload
return;
}
if (character->ps.shotsRemaining > 0)
{ // Don't reload if we're still trying to fire a burst
return;
}
// FIXME - Make sure we have ammo to put in our weapon
 
character->ps.weaponState = WEAPONSTATE_RELOADING;
 
if (character->ps.weaponTime <= GameTime)
{ // Ready to move to the next phase of our reload
if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_READY)
{ // we've finished reloading apparently?
character->ps.weaponState = WEAPONSTATE_READY;
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_REMOVING_OLD_AMMO)
{ // For any weapon type, adding new ammo will directly follow in from removing old
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_ADDING_NEW_AMMO;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].magInsertTime;
character->ps.magazineAmmo[character->ps.weapon] = 0;
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_ADDING_NEW_AMMO)
{ // Just finished adding a round/magazine/whatever
if ((loadType == WTYPE_HAMMER_BREAK || loadType == WTYPE_HAMMER_BREAK_MULTI ||
loadType == WTYPE_BOLTACTION_BREECHLOAD || loadType == WTYPE_AUTO_BREECHLOAD)
&& character->ps.magazineAmmo[character->ps.weapon] < character->weaponSlot[character->ps.weapon].magazineSize)
{ // A weapon that loads one round at a time, and we have room for another
character->ps.magazineAmmo[character->ps.weapon]++; // FIXME - This could add more than one round?
// FIXME - remove a round from our ammo reserves
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].magInsertTime;
}
else if (loadType == WTYPE_HAMMER_BREAK || loadType == WTYPE_HAMMER_BREAK_MULTI ||
loadType == WTYPE_BOLTACTION_BREECHLOAD)
{ // A weapon that loads one at a time, but is already full and needs closing
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_CLOSING;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].weaponCloseTime;
}
else if (loadType == WTYPE_AUTO_BREECHLOAD && character->ps.chamberedAmmo[character->ps.weapon] < character->weaponSlot[character->ps.weapon].chamberedRounds)
{ // Needs to be cocked
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_COCKING;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].cockingTime;
}
else
{ // A weapon that fills up all in one go
character->ps.magazineAmmo[character->ps.weapon] = character->weaponSlot[character->ps.weapon].magazineSize; // FIXME - Add the amount of the mag we're holding in our hand, in case we're cancelling a reload
if (loadType == WTYPE_HAMMER_BREAKSIMULTANEOUS || loadType == WTYPE_HAMMER_BREAKSIMULTANEOUS_MULTI ||
loadType == WTYPE_BOLTACTION_CLIP || loadType == WTYPE_AUTO_CLIP || WTYPE_AUTO_BELT)
{ // Needs to be closed now the new ammo has been added
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_CLOSING;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].weaponCloseTime;
}
else if (character->ps.chamberedAmmo[character->ps.weapon] < character->weaponSlot[character->ps.weapon].chamberedRounds)
{ // Needs to be cocked immediately after adding the ammo, because there's an empty chamber
character->ps.magazineAmmo[character->ps.weapon] = character->weaponSlot[character->ps.weapon].magazineSize; // FIXME - Add the amount of the mag we're holding in our hand, in case we're cancelling a reload
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_COCKING;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].cockingTime;
}
else
{ // Doesn't need to be cocked or closed, ready to fire again
character->ps.magazineAmmo[character->ps.weapon] = character->weaponSlot[character->ps.weapon].magazineSize; // FIXME - Add the amount of the mag we're holding in our hand, in case we're cancelling a reload
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_READY;
character->ps.weaponState = WEAPONSTATE_READY;
}
}
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_OPENING)
{ // Just finished opening the weapon
if (loadType == WTYPE_HAMMER_BREAK || loadType == WTYPE_HAMMER_BREAKSIMULTANEOUS || 
loadType == WTYPE_HAMMER_BREAK_MULTI || loadType == WTYPE_HAMMER_BREAKSIMULTANEOUS_MULTI ||
loadType == WTYPE_AUTO_BELT)
{ // Old rounds have to be removed once the weapon is opened
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_REMOVING_OLD_AMMO;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].magPullTime;
}
else
{ // Can start adding rounds immediately after opening
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_ADDING_NEW_AMMO;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].magInsertTime;
}
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_CLOSING)
{ // Just finished closing the weapon
if (loadType == WTYPE_BOLTACTION_CLIP || loadType == WTYPE_BOLTACTION_BREECHLOAD)
{ // Closing the weapon cocks it, so we're ready to fire
character->ps.magazineAmmo[character->ps.weapon]--; // FIXME - could chamber !1 round?
character->ps.chamberedAmmo[character->ps.weapon]++; // FIXME - could chamber !1 round?
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_READY;
character->ps.weaponState = WEAPONSTATE_READY;
}
else
{ // Weapon needs to be cocked after closing
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_COCKING;
character->ps.weaponTime += character->weaponSlot[character->ps.weapon].cockingTime;
}
}
else if (character->ps.weaponLoadState[character->ps.weapon] == RELOADSTATE_COCKING)
{ // Just finished cocking the weapon, ready to fire
character->ps.magazineAmmo[character->ps.weapon]--; // FIXME - could chamber !1 round?
character->ps.chamberedAmmo[character->ps.weapon]++; // FIXME - could chamber !1 round?
character->ps.weaponLoadState[character->ps.weapon] = RELOADSTATE_READY;
character->ps.weaponState = WEAPONSTATE_READY;
}
}
}
}
 
void startWeaponReload(characterUnit_t *character)
{
completeWeapon_t *weapon = &character->weaponSlot[character->ps.weapon];
int *loadState = &character->ps.weaponLoadState[character->ps.weapon];
unsigned int *weaponTime = &character->ps.weaponTime;
 
if (character->ps.magazineAmmo[character->ps.weapon] >= weapon->magazineSize)
{ // Already a full mag, don't reload
return;
}
if (character->ps.shotsRemaining > 0)
{ // Don't reload if we're still trying to fire a burst
return;
}
// FIXME - Make sure we have ammo to put in our weapon
 
// Put us into the correct state for immediately after starting a reload
switch (character->weaponSlot[character->ps.weapon].loadType)
{
case WTYPE_MELEE:
return; // Melee shouldn't ever have to reload, right?
case WTYPE_HAMMER_BREAK:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_HAMMER_BREAKSIMULTANEOUS:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_HAMMER_BREAK_MULTI:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_HAMMER_BREAKSIMULTANEOUS_MULTI:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_BOLTACTION_CLIP:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_BOLTACTION_BREECHLOAD:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_BOLTACTION_MAGAZINE:
*loadState = RELOADSTATE_REMOVING_OLD_AMMO;
*weaponTime = GameTime + weapon->magPullTime;
break;
case WTYPE_AUTO_CLIP:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_AUTO_MAGAZINE:
*loadState = RELOADSTATE_REMOVING_OLD_AMMO;
*weaponTime = GameTime + weapon->magPullTime;
break;
case WTYPE_AUTO_MAGAZINE_SELFEJECTING:
*loadState = RELOADSTATE_ADDING_NEW_AMMO;
*weaponTime = GameTime + weapon->magInsertTime;
break;
case WTYPE_AUTO_BELT:
*loadState = RELOADSTATE_OPENING;
*weaponTime = GameTime + weapon->weaponOpenTime;
break;
case WTYPE_AUTO_BREECHLOAD:
*loadState = RELOADSTATE_ADDING_NEW_AMMO;
*weaponTime = GameTime + weapon->magInsertTime;
break;
default:
return;
}
 
character->ps.weaponState = WEAPONSTATE_RELOADING;
}

I'll let you know if it works. Edit: It didn't, but now it does.

 

Also the forum deleted all my indentations, but that just adds to the horror.




#5100791 PUTT Updates and Finals Thread

Posted by OandO on 12 October 2013 - 08:29 AM

The absolute quickest collision detection and resolution I could come up with:

 

Edit: Isometric 2D is allowed right? Yes? Ok good. http://img853.imageshack.us/img853/9025/qn9b.png




#5099226 Power Up Table Tennis Contest

Posted by OandO on 06 October 2013 - 05:45 PM

I have uni stuff to do, I got to this topic late, but screw it, I'm in.




#5093813 Gameplay or story first?

Posted by OandO on 13 September 2013 - 11:24 AM

If you have a story in mind, story first. If you have certain gameplay in mind, gameplay first. Obvious answer is obvious.




#5084384 Amusing glitch gallery

Posted by OandO on 09 August 2013 - 07:05 AM

I don't have a screenshot or video of this (and it's been fixed now), but I was working on a physics-based walk cycle for a 2D character a little while ago. Spamming the left and right buttons would cause you to lift off the ground and fly away...




#5048298 Mahjong based tile perspective

Posted by OandO on 30 March 2013 - 07:53 AM

Surely the simplest solution for this particular case (assuming the tiles are always seemingly extruded the same way) would just to render from right to left?




#4978673 Problem with texture. It renders a solid color...

Posted by OandO on 10 September 2012 - 01:38 PM

I'm still not entirely familiar with the newer GLSL yet, but you've got "out out_uv" and in in_uv". Surely these variables should have the same name?


PARTNERS