diff --git a/assets/levelY.gif b/assets/levelY.gif index 606fe39..31ecdff 100644 Binary files a/assets/levelY.gif and b/assets/levelY.gif differ diff --git a/main.c b/main.c index 1c37ad6..89f744e 100755 --- a/main.c +++ b/main.c @@ -1086,6 +1086,44 @@ RCL_Unit SFG_floorCollisionHeightAt(int16_t x, int16_t y) SFG_getItemCollisionMapBit(x,y) * RCL_UNITS_PER_SQUARE; } +void SFG_getPlayerWeaponInfo( + uint8_t *ammoType, uint8_t *projectileCount, uint8_t *canShoot) +{ + *ammoType = SFG_weaponAmmo(SFG_player.weapon); + + *projectileCount = SFG_GET_WEAPON_PROJECTILE_COUNT(SFG_player.weapon); + +#if SFG_INFINITE_AMMO + *canShoot = 1; +#else + *canShoot = + (*ammoType == SFG_AMMO_NONE || + SFG_player.ammo[*ammoType] >= *projectileCount); +#endif +} + +void SFG_playerRotateWeapon(uint8_t next) +{ + RCL_Unit initialWeapon = SFG_player.weapon; + RCL_Unit increment = next ? 1 : -1; + + while (1) + { + SFG_player.weapon = + RCL_wrap(SFG_player.weapon + increment,SFG_WEAPONS_TOTAL); + + if (SFG_player.weapon == initialWeapon) + break; + + uint8_t ammo, projectileCount, canShoot; + + SFG_getPlayerWeaponInfo(&ammo,&projectileCount,&canShoot); + + if (canShoot) + break; + } +} + void SFG_initPlayer() { RCL_initCamera(&SFG_player.camera); @@ -1118,6 +1156,9 @@ void SFG_initPlayer() SFG_player.weapon = 2; + SFG_playerRotateWeapon(1); // this chooses weapon with ammo available + SFG_playerRotateWeapon(0); + SFG_player.weaponCooldownStartFrame = SFG_game.frame; SFG_player.lastHurtFrame = SFG_game.frame; SFG_player.lastItemTakenFrame = SFG_game.frame; @@ -1439,44 +1480,6 @@ void SFG_init() #endif } -void SFG_getPlayerWeaponInfo( - uint8_t *ammoType, uint8_t *projectileCount, uint8_t *canShoot) -{ - *ammoType = SFG_weaponAmmo(SFG_player.weapon); - - *projectileCount = SFG_GET_WEAPON_PROJECTILE_COUNT(SFG_player.weapon); - -#if SFG_INFINITE_AMMO - *canShoot = 1; -#else - *canShoot = - (*ammoType == SFG_AMMO_NONE || - SFG_player.ammo[*ammoType] >= *projectileCount); -#endif -} - -void SFG_playerRotateWeapon(uint8_t next) -{ - RCL_Unit initialWeapon = SFG_player.weapon; - RCL_Unit increment = next ? 1 : -1; - - while (1) - { - SFG_player.weapon = - RCL_wrap(SFG_player.weapon + increment,SFG_WEAPONS_TOTAL); - - if (SFG_player.weapon == initialWeapon) - break; - - uint8_t ammo, projectileCount, canShoot; - - SFG_getPlayerWeaponInfo(&ammo,&projectileCount,&canShoot); - - if (canShoot) - break; - } -} - /** Adds new projectile to the current level, return 1 if added, 0 if not (max count reached). diff --git a/settings.h b/settings.h index 6a78749..3a7e5e5 100644 --- a/settings.h +++ b/settings.h @@ -204,12 +204,12 @@ /** Developer cheat for having infinite ammo in all weapons. */ -#define SFG_INFINITE_AMMO 1 +#define SFG_INFINITE_AMMO 0 /** Developer cheat for immortality. */ -#define SFG_IMMORTAL 1 +#define SFG_IMMORTAL 0 /** Turn on for previes mode for map editing (flying, noclip, fast movement etc.).