mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-24 09:52:20 -05:00
Add autoaim
This commit is contained in:
parent
8cb615efe6
commit
3f7160ae46
@ -1,6 +1,6 @@
|
|||||||
// Pokitto config required by PokittoLib
|
// Pokitto config required by PokittoLib
|
||||||
|
|
||||||
//#define PROJ_SHOW_FPS_COUNTER
|
#define PROJ_SHOW_FPS_COUNTER
|
||||||
#define PROJ_SCREENMODE 13
|
#define PROJ_SCREENMODE 13
|
||||||
#define PROJ_MODE13 1
|
#define PROJ_MODE13 1
|
||||||
#define PROJ_ENABLE_SOUND 1
|
#define PROJ_ENABLE_SOUND 1
|
||||||
|
2
TODO.txt
2
TODO.txt
@ -2,7 +2,6 @@ general:
|
|||||||
|
|
||||||
- Ability to play SFX slower to e.g. give some monsters lower pitch?
|
- Ability to play SFX slower to e.g. give some monsters lower pitch?
|
||||||
- Rewrite python scripts to C (faster, less bloat).
|
- Rewrite python scripts to C (faster, less bloat).
|
||||||
- Option for vertical auto aim?
|
|
||||||
- Try to recolor textures and give them a bit more of variety.
|
- Try to recolor textures and give them a bit more of variety.
|
||||||
- Make monsters die when squeezed?
|
- Make monsters die when squeezed?
|
||||||
- On Win$hit builds display an anti-windshit text, by macro.
|
- On Win$hit builds display an anti-windshit text, by macro.
|
||||||
@ -154,6 +153,7 @@ bugs:
|
|||||||
done:
|
done:
|
||||||
|
|
||||||
- add headbob
|
- add headbob
|
||||||
|
- option for vertical auto aim
|
||||||
- add blinking
|
- add blinking
|
||||||
- make zBuffer 8bit only?
|
- make zBuffer 8bit only?
|
||||||
- texture coords of floor walls should start from the floor? NO, CAUSES ISSUES
|
- texture coords of floor walls should start from the floor? NO, CAUSES ISSUES
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.9 KiB |
103
game.h
103
game.h
@ -2621,6 +2621,72 @@ static inline uint16_t SFG_getMapRevealBit(uint8_t squareX, uint8_t squareY)
|
|||||||
return 1 << ((squareY / 16) * 4 + squareX / 16);
|
return 1 << ((squareY / 16) * 4 + squareX / 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks a 3D point visibility from player's position (WITHOUT considering
|
||||||
|
facing direction).
|
||||||
|
*/
|
||||||
|
static inline uint8_t SFG_spriteIsVisible(RCL_Vector2D pos, RCL_Unit height,
|
||||||
|
uint8_t spriteSize)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
RCL_castRay3D(
|
||||||
|
SFG_player.camera.position,
|
||||||
|
SFG_player.camera.height,
|
||||||
|
pos,
|
||||||
|
height,
|
||||||
|
SFG_floorHeightAt,
|
||||||
|
SFG_ceilingHeightAt,
|
||||||
|
SFG_game.rayConstraints
|
||||||
|
) == RCL_UNITS_PER_SQUARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a tangent in RCL_Unit of vertical autoaim, given current game state.
|
||||||
|
*/
|
||||||
|
RCL_Unit SFG_autoaimVertically()
|
||||||
|
{
|
||||||
|
for (uint16_t i = 0; i < SFG_currentLevel.monsterRecordCount; ++i)
|
||||||
|
{
|
||||||
|
SFG_MonsterRecord m = SFG_currentLevel.monsterRecords[i];
|
||||||
|
|
||||||
|
if (SFG_MR_STATE(m) == SFG_MONSTER_STATE_INACTIVE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RCL_Vector2D worldPosition, toMonster;
|
||||||
|
|
||||||
|
worldPosition.x = SFG_MONSTER_COORD_TO_RCL_UNITS(m.coords[0]);
|
||||||
|
worldPosition.y = SFG_MONSTER_COORD_TO_RCL_UNITS(m.coords[1]);
|
||||||
|
|
||||||
|
toMonster.x = worldPosition.x - SFG_player.camera.position.x;
|
||||||
|
toMonster.y = worldPosition.y - SFG_player.camera.position.y;
|
||||||
|
|
||||||
|
if (RCL_abs(
|
||||||
|
RCL_vectorsAngleCos(SFG_player.direction,toMonster)
|
||||||
|
- RCL_UNITS_PER_SQUARE) < SFG_VERTICAL_AUTOAIM_ANGLE_THRESHOLD)
|
||||||
|
{
|
||||||
|
uint8_t spriteSize = SFG_GET_MONSTER_SPRITE_SIZE(
|
||||||
|
SFG_MONSTER_TYPE_TO_INDEX(SFG_MR_TYPE(m)));
|
||||||
|
|
||||||
|
RCL_Unit worldHeight =
|
||||||
|
SFG_floorHeightAt(
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(m.coords[0]),
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(m.coords[1]))
|
||||||
|
+
|
||||||
|
SFG_SPRITE_SIZE_TO_HEIGHT_ABOVE_GROUND(spriteSize);
|
||||||
|
|
||||||
|
if (SFG_spriteIsVisible(worldPosition,worldHeight,spriteSize))
|
||||||
|
{
|
||||||
|
RCL_Unit distance = RCL_len(toMonster);
|
||||||
|
|
||||||
|
return ((worldHeight - SFG_player.camera.height) * RCL_UNITS_PER_SQUARE)
|
||||||
|
/ distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Part of SFG_gameStep() for SFG_GAME_STATE_PLAYING.
|
Part of SFG_gameStep() for SFG_GAME_STATE_PLAYING.
|
||||||
*/
|
*/
|
||||||
@ -2650,8 +2716,8 @@ void SFG_gameStepPlaying()
|
|||||||
int8_t shearing = 0;
|
int8_t shearing = 0;
|
||||||
|
|
||||||
if (SFG_keyJustPressed(SFG_KEY_TOGGLE_FREELOOK))
|
if (SFG_keyJustPressed(SFG_KEY_TOGGLE_FREELOOK))
|
||||||
SFG_game.settings =
|
SFG_game.settings = (SFG_game.settings & 0x04) ?
|
||||||
(~SFG_game.settings & 0x08) | (SFG_game.settings & ~0x08);
|
(SFG_game.settings & ~0x0c) : (SFG_game.settings | 0x0c );
|
||||||
|
|
||||||
#if SFG_PREVIEW_MODE == 0
|
#if SFG_PREVIEW_MODE == 0
|
||||||
if (
|
if (
|
||||||
@ -2720,6 +2786,16 @@ void SFG_gameStepPlaying()
|
|||||||
(SFG_player.camera.direction - SFG_PROJECTILE_SPREAD_ANGLE / 2)
|
(SFG_player.camera.direction - SFG_PROJECTILE_SPREAD_ANGLE / 2)
|
||||||
+ angleAdd;
|
+ angleAdd;
|
||||||
|
|
||||||
|
RCL_Unit projectileSpeed = SFG_GET_PROJECTILE_SPEED_UPS(projectile);
|
||||||
|
|
||||||
|
/* Vertical speed will be either determined by autoaim (if shearing is
|
||||||
|
off) or the camera shear value. */
|
||||||
|
RCL_Unit verticalSpeed = (SFG_game.settings & 0x04) ?
|
||||||
|
(SFG_player.camera.shear * projectileSpeed) /
|
||||||
|
SFG_CAMERA_MAX_SHEAR_PIXELS
|
||||||
|
:
|
||||||
|
(projectileSpeed * SFG_autoaimVertically()) / RCL_UNITS_PER_SQUARE;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < projectileCount; ++i)
|
for (uint8_t i = 0; i < projectileCount; ++i)
|
||||||
{
|
{
|
||||||
SFG_launchProjectile(
|
SFG_launchProjectile(
|
||||||
@ -2727,9 +2803,7 @@ void SFG_gameStepPlaying()
|
|||||||
SFG_player.camera.position,
|
SFG_player.camera.position,
|
||||||
SFG_player.camera.height,
|
SFG_player.camera.height,
|
||||||
RCL_angleToDirection(direction),
|
RCL_angleToDirection(direction),
|
||||||
(SFG_player.camera.shear *
|
verticalSpeed,
|
||||||
SFG_GET_PROJECTILE_SPEED_UPS(projectile)) /
|
|
||||||
SFG_CAMERA_MAX_SHEAR_PIXELS,
|
|
||||||
SFG_PROJECTILE_SPAWN_OFFSET
|
SFG_PROJECTILE_SPAWN_OFFSET
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -3850,25 +3924,6 @@ void SFG_drawWinOverlay()
|
|||||||
#undef INNER_STRIP_HEIGHT
|
#undef INNER_STRIP_HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Checks a 3D point visibility from player's position (WITHOUT considering
|
|
||||||
facing direction).
|
|
||||||
*/
|
|
||||||
static inline uint8_t SFG_spriteIsVisible(RCL_Vector2D pos, RCL_Unit height,
|
|
||||||
uint8_t spriteSize)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
RCL_castRay3D(
|
|
||||||
SFG_player.camera.position,
|
|
||||||
SFG_player.camera.height,
|
|
||||||
pos,
|
|
||||||
height,
|
|
||||||
SFG_floorHeightAt,
|
|
||||||
SFG_ceilingHeightAt,
|
|
||||||
SFG_game.rayConstraints
|
|
||||||
) == RCL_UNITS_PER_SQUARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SFG_draw()
|
void SFG_draw()
|
||||||
{
|
{
|
||||||
#if SFG_BACKGROUND_BLUR != 0
|
#if SFG_BACKGROUND_BLUR != 0
|
||||||
|
@ -164,10 +164,6 @@ int main()
|
|||||||
{
|
{
|
||||||
if (pokitto.update())
|
if (pokitto.update())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (SFG_game.frame % 32 == 0)
|
|
||||||
printf("%d\n",Pokitto::Core::fps_counter);
|
|
||||||
|
|
||||||
SFG_mainLoopBody();
|
SFG_mainLoopBody();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
mbed_config.h
Normal file
25
mbed_config.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* mbed SDK
|
||||||
|
* Copyright (c) 2017 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Automatically generated configuration file.
|
||||||
|
// DO NOT EDIT, content will be overwritten.
|
||||||
|
|
||||||
|
#ifndef __MBED_CONFIG_DATA__
|
||||||
|
#define __MBED_CONFIG_DATA__
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -307,6 +307,15 @@
|
|||||||
#define SFG_OS_IS_MALWARE 0
|
#define SFG_OS_IS_MALWARE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
Angle difference, as a cos value in RCL_Units, between the player and a
|
||||||
|
monster, at which vertical autoaim will trigger. If the angle is greater, a
|
||||||
|
shot will go directly forward.
|
||||||
|
*/
|
||||||
|
#ifndef SFG_VERTICAL_AUTOAIM_ANGLE_THRESHOLD
|
||||||
|
#define SFG_VERTICAL_AUTOAIM_ANGLE_THRESHOLD 50
|
||||||
|
#endif
|
||||||
|
|
||||||
//------ developer/debug settings ------
|
//------ developer/debug settings ------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user