mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-21 08:25:05 -05:00
Polish controls
This commit is contained in:
parent
5b518b8024
commit
2deac9d7e5
10
game.h
10
game.h
@ -3064,9 +3064,9 @@ void SFG_gameStepPlaying()
|
|||||||
|
|
||||||
uint8_t shearingOn = SFG_game.settings & 0x04;
|
uint8_t shearingOn = SFG_game.settings & 0x04;
|
||||||
|
|
||||||
if (SFG_keyIsDown(SFG_KEY_A))
|
if (SFG_keyIsDown(SFG_KEY_B))
|
||||||
{
|
{
|
||||||
if (shearingOn) // A + U/D: shearing (if on)
|
if (shearingOn) // B + U/D: shearing (if on)
|
||||||
{
|
{
|
||||||
if (SFG_keyIsDown(SFG_KEY_UP))
|
if (SFG_keyIsDown(SFG_KEY_UP))
|
||||||
{
|
{
|
||||||
@ -3105,7 +3105,7 @@ void SFG_gameStepPlaying()
|
|||||||
canSwitchWeapon)
|
canSwitchWeapon)
|
||||||
SFG_playerRotateWeapon(1);
|
SFG_playerRotateWeapon(1);
|
||||||
}
|
}
|
||||||
else if (!SFG_keyIsDown(SFG_KEY_A)) // L/R: turning
|
else if (!SFG_keyIsDown(SFG_KEY_B)) // L/R: turning
|
||||||
{
|
{
|
||||||
if (SFG_keyIsDown(SFG_KEY_LEFT))
|
if (SFG_keyIsDown(SFG_KEY_LEFT))
|
||||||
{
|
{
|
||||||
@ -3119,7 +3119,7 @@ void SFG_gameStepPlaying()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SFG_keyIsDown(SFG_KEY_A) || !shearingOn) // U/D: movement
|
if (!SFG_keyIsDown(SFG_KEY_B) || !shearingOn) // U/D: movement
|
||||||
{
|
{
|
||||||
if (SFG_keyIsDown(SFG_KEY_UP))
|
if (SFG_keyIsDown(SFG_KEY_UP))
|
||||||
{
|
{
|
||||||
@ -3459,7 +3459,7 @@ void SFG_gameStepPlaying()
|
|||||||
|
|
||||||
#if SFG_PREVIEW_MODE == 0
|
#if SFG_PREVIEW_MODE == 0
|
||||||
if (
|
if (
|
||||||
SFG_keyIsDown(SFG_KEY_B) &&
|
SFG_keyIsDown(SFG_KEY_A) &&
|
||||||
!SFG_keyIsDown(SFG_KEY_C) &&
|
!SFG_keyIsDown(SFG_KEY_C) &&
|
||||||
(SFG_player.weaponCooldownFrames == 0))
|
(SFG_player.weaponCooldownFrames == 0))
|
||||||
{
|
{
|
||||||
|
137
main_csfml.c
137
main_csfml.c
@ -19,6 +19,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <SFML/Audio/Types.h>
|
||||||
|
|
||||||
#define SFG_SCREEN_RESOLUTION_X 640
|
#define SFG_SCREEN_RESOLUTION_X 640
|
||||||
#define SFG_SCREEN_RESOLUTION_Y 480
|
#define SFG_SCREEN_RESOLUTION_Y 480
|
||||||
|
|
||||||
@ -29,6 +31,7 @@
|
|||||||
#define WINDOW_SIZE (SFG_SCREEN_RESOLUTION_X * SFG_SCREEN_RESOLUTION_Y)
|
#define WINDOW_SIZE (SFG_SCREEN_RESOLUTION_X * SFG_SCREEN_RESOLUTION_Y)
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "sounds.h"
|
||||||
|
|
||||||
uint32_t windowPixels[WINDOW_SIZE];
|
uint32_t windowPixels[WINDOW_SIZE];
|
||||||
|
|
||||||
@ -39,55 +42,26 @@ sfRenderWindow* window;
|
|||||||
|
|
||||||
int8_t SFG_keyPressed(uint8_t key)
|
int8_t SFG_keyPressed(uint8_t key)
|
||||||
{
|
{
|
||||||
#define k(x) sfKeyboard_isKeyPressed(x)
|
#define k(x) sfKeyboard_isKeyPressed(sfKey ## x)
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case SFG_KEY_UP:
|
case SFG_KEY_UP: return k(W) || k(Up) || k(Num8); break;
|
||||||
return k(sfKeyW) || k(sfKeyUp) || k(sfKeyNum8);
|
case SFG_KEY_RIGHT: return k(E) || k(Right) || k(Num6);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SFG_KEY_RIGHT:
|
|
||||||
return k(sfKeyE) || k(sfKeyRight) || k(sfKeyNum6);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_DOWN:
|
case SFG_KEY_DOWN:
|
||||||
return k(sfKeyS) || k(sfKeyDown) || k(sfKeyNum5) || k (sfKeyNum2);
|
return k(S) || k(Down) || k(Num5) || k (Num2); break;
|
||||||
break;
|
case SFG_KEY_LEFT: return k(Q) || k(Left) || k(Num4); break;
|
||||||
|
|
||||||
case SFG_KEY_LEFT:
|
|
||||||
return k(sfKeyQ) || k(sfKeyLeft) || k(sfKeyNum4);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_A:
|
case SFG_KEY_A:
|
||||||
return k(sfKeyG) || k(sfKeyReturn) || k(sfKeyLShift);
|
return k(J) || k(Return) || k(LShift); break;
|
||||||
break;
|
case SFG_KEY_B: return k(K) || k(LControl) || k(RControl)
|
||||||
|
|| sfMouse_isButtonPressed(sfMouseLeft); break;
|
||||||
case SFG_KEY_B:
|
case SFG_KEY_C: return k(L); break;
|
||||||
return k(sfKeyH) || k(sfKeyLControl) || k(sfKeyRControl)
|
case SFG_KEY_JUMP: return k(Space); break;
|
||||||
|| sfMouse_isButtonPressed(sfMouseLeft);
|
case SFG_KEY_STRAFE_LEFT: return k(A) || k(Num7); break;
|
||||||
break;
|
case SFG_KEY_STRAFE_RIGHT: return k(D) || k(Num9); break;
|
||||||
|
case SFG_KEY_MAP: return k(Tab); break;
|
||||||
case SFG_KEY_C:
|
case SFG_KEY_CYCLE_WEAPON: return k(F);
|
||||||
return k(sfKeyJ);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_JUMP:
|
|
||||||
return k(sfKeySpace);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_STRAFE_LEFT:
|
|
||||||
return k(sfKeyA) || k(sfKeyNum7);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_STRAFE_RIGHT:
|
|
||||||
return k(sfKeyD) || k(sfKeyNum9);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_MAP:
|
|
||||||
return k(sfKeyTab);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_TOGGLE_FREELOOK:
|
case SFG_KEY_TOGGLE_FREELOOK:
|
||||||
return sfMouse_isButtonPressed(sfMouseRight);
|
return sfMouse_isButtonPressed(sfMouseRight);
|
||||||
break;
|
break;
|
||||||
@ -122,20 +96,19 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SFG_KEY_MENU:
|
case SFG_KEY_MENU: return sfKeyboard_isKeyPressed(sfKeyEscape); break;
|
||||||
return sfKeyboard_isKeyPressed(sfKeyEscape);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: return 0; break;
|
default: return 0; break;
|
||||||
|
|
||||||
#undef k
|
#undef k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
||||||
{
|
{
|
||||||
sfVector2u s = sfWindow_getSize(window);
|
sfVector2u s = sfWindow_getSize((const sfWindow *) window);
|
||||||
sfVector2i p = sfMouse_getPosition(window);
|
sfVector2i p = sfMouse_getPosition((const sfWindow *) window);
|
||||||
|
|
||||||
s.x /= 2;
|
s.x /= 2;
|
||||||
s.y /= 2;
|
s.y /= 2;
|
||||||
@ -146,7 +119,7 @@ void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
|||||||
p.x = s.x;
|
p.x = s.x;
|
||||||
p.y = s.y;
|
p.y = s.y;
|
||||||
|
|
||||||
sfMouse_setPosition(p,window);
|
sfMouse_setPosition(p,(const sfWindow *) window);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SFG_getTimeMs()
|
uint32_t SFG_getTimeMs()
|
||||||
@ -166,9 +139,6 @@ void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex)
|
|||||||
windowPixels[y * SFG_SCREEN_RESOLUTION_X + x] = paletteRGB32[colorIndex];
|
windowPixels[y * SFG_SCREEN_RESOLUTION_X + x] = paletteRGB32[colorIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SFG_enableMusic(uint8_t enable)
|
void SFG_enableMusic(uint8_t enable)
|
||||||
{
|
{
|
||||||
@ -180,11 +150,51 @@ void SFG_processEvent(uint8_t event, uint8_t data)
|
|||||||
|
|
||||||
void SFG_save(uint8_t data[SFG_SAVE_SIZE])
|
void SFG_save(uint8_t data[SFG_SAVE_SIZE])
|
||||||
{
|
{
|
||||||
|
FILE *f = fopen("anarch.sav","wb");
|
||||||
|
|
||||||
|
if (f == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fwrite(data,1,SFG_SAVE_SIZE,f);
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE])
|
uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE])
|
||||||
{
|
{
|
||||||
return 0;
|
FILE *f = fopen("anarch.sav","rb");
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
{
|
||||||
|
fread(data,1,SFG_SAVE_SIZE,f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sfInputStream soundStream;
|
||||||
|
|
||||||
|
uint64_t soundPos = 0;
|
||||||
|
|
||||||
|
sfInt64 soundRead(void* data, sfInt64 size, void* userData)
|
||||||
|
{
|
||||||
|
soundPos += size;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
sfInt64 soundSize(void* userData)
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -194,6 +204,14 @@ int main()
|
|||||||
clock = sfClock_create();
|
clock = sfClock_create();
|
||||||
sfClock_restart(clock);
|
sfClock_restart(clock);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SFG_init();
|
SFG_init();
|
||||||
|
|
||||||
for (int i = 0; i < 256; ++i) // precompute RGB palette
|
for (int i = 0; i < 256; ++i) // precompute RGB palette
|
||||||
@ -212,8 +230,11 @@ int main()
|
|||||||
window = sfRenderWindow_create(mode, "Anarch", sfResize | sfClose, NULL);
|
window = sfRenderWindow_create(mode, "Anarch", sfResize | sfClose, NULL);
|
||||||
sfSprite_setTexture(windowSprite, windowTexture, sfTrue);
|
sfSprite_setTexture(windowSprite, windowTexture, sfTrue);
|
||||||
|
|
||||||
sfWindow_setMouseCursorVisible(window,sfFalse);
|
sfWindow_setMouseCursorVisible((sfWindow *) window,sfFalse);
|
||||||
sfWindow_setVerticalSyncEnabled(window,sfFalse);
|
sfWindow_setVerticalSyncEnabled((sfWindow *) window,sfFalse);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t lastAudioUpdate = 0;
|
||||||
|
|
||||||
while (sfRenderWindow_isOpen(window))
|
while (sfRenderWindow_isOpen(window))
|
||||||
{
|
{
|
||||||
@ -224,10 +245,11 @@ int main()
|
|||||||
if (!SFG_mainLoopBody())
|
if (!SFG_mainLoopBody())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sfTexture_updateFromPixels(windowTexture,windowPixels,SFG_SCREEN_RESOLUTION_X,SFG_SCREEN_RESOLUTION_Y,0,0);
|
sfTexture_updateFromPixels(windowTexture,(const sfUint8 *) windowPixels,SFG_SCREEN_RESOLUTION_X,SFG_SCREEN_RESOLUTION_Y,0,0);
|
||||||
sfRenderWindow_clear(window, sfBlack);
|
sfRenderWindow_clear(window, sfBlack);
|
||||||
sfRenderWindow_drawSprite(window, windowSprite, NULL);
|
sfRenderWindow_drawSprite(window, windowSprite, NULL);
|
||||||
sfRenderWindow_display(window);
|
sfRenderWindow_display(window);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sfSprite_destroy(windowSprite);
|
sfSprite_destroy(windowSprite);
|
||||||
@ -235,5 +257,6 @@ int main()
|
|||||||
sfRenderWindow_destroy(window);
|
sfRenderWindow_destroy(window);
|
||||||
sfClock_destroy(clock);
|
sfClock_destroy(clock);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -208,10 +208,10 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
case SFG_KEY_RIGHT: return k(RIGHT) || k(E) || k(KP_6); break;
|
case SFG_KEY_RIGHT: return k(RIGHT) || k(E) || k(KP_6); break;
|
||||||
case SFG_KEY_DOWN: return k(DOWN) || k(S) || k(KP_5) || k(KP_2); break;
|
case SFG_KEY_DOWN: return k(DOWN) || k(S) || k(KP_5) || k(KP_2); break;
|
||||||
case SFG_KEY_LEFT: return k(LEFT) || k(Q) || k(KP_4); break;
|
case SFG_KEY_LEFT: return k(LEFT) || k(Q) || k(KP_4); break;
|
||||||
case SFG_KEY_A: return k(G) || k(RETURN) || k(LSHIFT); break;
|
case SFG_KEY_A: return k(J) || k(RETURN) || k(LSHIFT); break;
|
||||||
case SFG_KEY_B: return k(H) || k(LCTRL) || k(RCTRL) ||
|
case SFG_KEY_B: return k(K) || k(LCTRL) || k(RCTRL) ||
|
||||||
sdlMouseButtonState & SDL_BUTTON_LMASK; break;
|
sdlMouseButtonState & SDL_BUTTON_LMASK; break;
|
||||||
case SFG_KEY_C: return k(J); break;
|
case SFG_KEY_C: return k(L); break;
|
||||||
case SFG_KEY_JUMP: return k(SPACE); break;
|
case SFG_KEY_JUMP: return k(SPACE); break;
|
||||||
case SFG_KEY_STRAFE_LEFT: return k(A) || k(KP_7); break;
|
case SFG_KEY_STRAFE_LEFT: return k(A) || k(KP_7); break;
|
||||||
case SFG_KEY_STRAFE_RIGHT: return k(D) || k(KP_9); break;
|
case SFG_KEY_STRAFE_RIGHT: return k(D) || k(KP_9); break;
|
||||||
|
@ -111,18 +111,18 @@ controls:
|
|||||||
- arrows, numpad, [W] [S] [A] [D] [Q] [R]: movement
|
- arrows, numpad, [W] [S] [A] [D] [Q] [R]: movement
|
||||||
- mouse: rotation, [LMB] shoot, [RMB] toggle free look, wheel weapon change
|
- mouse: rotation, [LMB] shoot, [RMB] toggle free look, wheel weapon change
|
||||||
- [SPACE]: jump
|
- [SPACE]: jump
|
||||||
- [G] [RETURN] [SHIFT]: game A button (confirm, strafe)
|
- [J] [RETURN] [SHIFT]: game A button (confirm, shoot)
|
||||||
- [H] [CTRL]: game B button (cancel, shoot)
|
- [K] [CTRL]: game B button (cancel, strafe, look)
|
||||||
- [O] [P] [X] [Y] [Z]: change weapons
|
- [L] [P] [X] [Y] [Z]: change weapons
|
||||||
- [TAB]: map
|
- [TAB]: map
|
||||||
- [ESCAPE]: menu
|
- [ESCAPE]: menu
|
||||||
|
|
||||||
general controls:
|
general controls:
|
||||||
|
|
||||||
- arrows: movement
|
- arrows: movement
|
||||||
- A: confirm
|
- A: confirm, shoot
|
||||||
A + arrows: strafe, look up/down
|
- B: cancel
|
||||||
- B: cancel, shoot
|
B + arrows: strafe, look up/down
|
||||||
- C:
|
- C:
|
||||||
C + UP: jump
|
C + UP: jump
|
||||||
C + DOWN: menu
|
C + DOWN: menu
|
||||||
|
Loading…
Reference in New Issue
Block a user