mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-21 23:08:49 -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;
|
||||
|
||||
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))
|
||||
{
|
||||
@ -3105,7 +3105,7 @@ void SFG_gameStepPlaying()
|
||||
canSwitchWeapon)
|
||||
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))
|
||||
{
|
||||
@ -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))
|
||||
{
|
||||
@ -3459,7 +3459,7 @@ void SFG_gameStepPlaying()
|
||||
|
||||
#if SFG_PREVIEW_MODE == 0
|
||||
if (
|
||||
SFG_keyIsDown(SFG_KEY_B) &&
|
||||
SFG_keyIsDown(SFG_KEY_A) &&
|
||||
!SFG_keyIsDown(SFG_KEY_C) &&
|
||||
(SFG_player.weaponCooldownFrames == 0))
|
||||
{
|
||||
|
137
main_csfml.c
137
main_csfml.c
@ -19,6 +19,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <SFML/Audio/Types.h>
|
||||
|
||||
#define SFG_SCREEN_RESOLUTION_X 640
|
||||
#define SFG_SCREEN_RESOLUTION_Y 480
|
||||
|
||||
@ -29,6 +31,7 @@
|
||||
#define WINDOW_SIZE (SFG_SCREEN_RESOLUTION_X * SFG_SCREEN_RESOLUTION_Y)
|
||||
|
||||
#include "game.h"
|
||||
#include "sounds.h"
|
||||
|
||||
uint32_t windowPixels[WINDOW_SIZE];
|
||||
|
||||
@ -39,55 +42,26 @@ sfRenderWindow* window;
|
||||
|
||||
int8_t SFG_keyPressed(uint8_t key)
|
||||
{
|
||||
#define k(x) sfKeyboard_isKeyPressed(x)
|
||||
#define k(x) sfKeyboard_isKeyPressed(sfKey ## x)
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case SFG_KEY_UP:
|
||||
return k(sfKeyW) || k(sfKeyUp) || k(sfKeyNum8);
|
||||
case SFG_KEY_UP: return k(W) || k(Up) || k(Num8); break;
|
||||
case SFG_KEY_RIGHT: return k(E) || k(Right) || k(Num6);
|
||||
break;
|
||||
|
||||
case SFG_KEY_RIGHT:
|
||||
return k(sfKeyE) || k(sfKeyRight) || k(sfKeyNum6);
|
||||
break;
|
||||
|
||||
case SFG_KEY_DOWN:
|
||||
return k(sfKeyS) || k(sfKeyDown) || k(sfKeyNum5) || k (sfKeyNum2);
|
||||
break;
|
||||
|
||||
case SFG_KEY_LEFT:
|
||||
return k(sfKeyQ) || k(sfKeyLeft) || k(sfKeyNum4);
|
||||
break;
|
||||
|
||||
return k(S) || k(Down) || k(Num5) || k (Num2); break;
|
||||
case SFG_KEY_LEFT: return k(Q) || k(Left) || k(Num4); break;
|
||||
case SFG_KEY_A:
|
||||
return k(sfKeyG) || k(sfKeyReturn) || k(sfKeyLShift);
|
||||
break;
|
||||
|
||||
case SFG_KEY_B:
|
||||
return k(sfKeyH) || k(sfKeyLControl) || k(sfKeyRControl)
|
||||
|| sfMouse_isButtonPressed(sfMouseLeft);
|
||||
break;
|
||||
|
||||
case SFG_KEY_C:
|
||||
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;
|
||||
|
||||
return k(J) || k(Return) || k(LShift); break;
|
||||
case SFG_KEY_B: return k(K) || k(LControl) || k(RControl)
|
||||
|| sfMouse_isButtonPressed(sfMouseLeft); break;
|
||||
case SFG_KEY_C: return k(L); break;
|
||||
case SFG_KEY_JUMP: return k(Space); break;
|
||||
case SFG_KEY_STRAFE_LEFT: return k(A) || k(Num7); break;
|
||||
case SFG_KEY_STRAFE_RIGHT: return k(D) || k(Num9); break;
|
||||
case SFG_KEY_MAP: return k(Tab); break;
|
||||
case SFG_KEY_CYCLE_WEAPON: return k(F);
|
||||
case SFG_KEY_TOGGLE_FREELOOK:
|
||||
return sfMouse_isButtonPressed(sfMouseRight);
|
||||
break;
|
||||
@ -122,20 +96,19 @@ int8_t SFG_keyPressed(uint8_t key)
|
||||
*/
|
||||
break;
|
||||
|
||||
case SFG_KEY_MENU:
|
||||
return sfKeyboard_isKeyPressed(sfKeyEscape);
|
||||
break;
|
||||
|
||||
case SFG_KEY_MENU: return sfKeyboard_isKeyPressed(sfKeyEscape); break;
|
||||
default: return 0; break;
|
||||
|
||||
#undef k
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
||||
{
|
||||
sfVector2u s = sfWindow_getSize(window);
|
||||
sfVector2i p = sfMouse_getPosition(window);
|
||||
sfVector2u s = sfWindow_getSize((const sfWindow *) window);
|
||||
sfVector2i p = sfMouse_getPosition((const sfWindow *) window);
|
||||
|
||||
s.x /= 2;
|
||||
s.y /= 2;
|
||||
@ -146,7 +119,7 @@ void SFG_getMouseOffset(int16_t *x, int16_t *y)
|
||||
p.x = s.x;
|
||||
p.y = s.y;
|
||||
|
||||
sfMouse_setPosition(p,window);
|
||||
sfMouse_setPosition(p,(const sfWindow *) window);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
||||
{
|
||||
}
|
||||
|
||||
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])
|
||||
{
|
||||
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])
|
||||
{
|
||||
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()
|
||||
@ -194,6 +204,14 @@ int main()
|
||||
clock = sfClock_create();
|
||||
sfClock_restart(clock);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SFG_init();
|
||||
|
||||
for (int i = 0; i < 256; ++i) // precompute RGB palette
|
||||
@ -212,8 +230,11 @@ int main()
|
||||
window = sfRenderWindow_create(mode, "Anarch", sfResize | sfClose, NULL);
|
||||
sfSprite_setTexture(windowSprite, windowTexture, sfTrue);
|
||||
|
||||
sfWindow_setMouseCursorVisible(window,sfFalse);
|
||||
sfWindow_setVerticalSyncEnabled(window,sfFalse);
|
||||
sfWindow_setMouseCursorVisible((sfWindow *) window,sfFalse);
|
||||
sfWindow_setVerticalSyncEnabled((sfWindow *) window,sfFalse);
|
||||
|
||||
|
||||
uint32_t lastAudioUpdate = 0;
|
||||
|
||||
while (sfRenderWindow_isOpen(window))
|
||||
{
|
||||
@ -224,10 +245,11 @@ int main()
|
||||
if (!SFG_mainLoopBody())
|
||||
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_drawSprite(window, windowSprite, NULL);
|
||||
sfRenderWindow_display(window);
|
||||
|
||||
}
|
||||
|
||||
sfSprite_destroy(windowSprite);
|
||||
@ -235,5 +257,6 @@ int main()
|
||||
sfRenderWindow_destroy(window);
|
||||
sfClock_destroy(clock);
|
||||
|
||||
|
||||
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_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_A: return k(G) || k(RETURN) || k(LSHIFT); break;
|
||||
case SFG_KEY_B: return k(H) || k(LCTRL) || k(RCTRL) ||
|
||||
case SFG_KEY_A: return k(J) || k(RETURN) || k(LSHIFT); break;
|
||||
case SFG_KEY_B: return k(K) || k(LCTRL) || k(RCTRL) ||
|
||||
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_STRAFE_LEFT: return k(A) || k(KP_7); 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
|
||||
- mouse: rotation, [LMB] shoot, [RMB] toggle free look, wheel weapon change
|
||||
- [SPACE]: jump
|
||||
- [G] [RETURN] [SHIFT]: game A button (confirm, strafe)
|
||||
- [H] [CTRL]: game B button (cancel, shoot)
|
||||
- [O] [P] [X] [Y] [Z]: change weapons
|
||||
- [J] [RETURN] [SHIFT]: game A button (confirm, shoot)
|
||||
- [K] [CTRL]: game B button (cancel, strafe, look)
|
||||
- [L] [P] [X] [Y] [Z]: change weapons
|
||||
- [TAB]: map
|
||||
- [ESCAPE]: menu
|
||||
|
||||
general controls:
|
||||
|
||||
- arrows: movement
|
||||
- A: confirm
|
||||
A + arrows: strafe, look up/down
|
||||
- B: cancel, shoot
|
||||
- A: confirm, shoot
|
||||
- B: cancel
|
||||
B + arrows: strafe, look up/down
|
||||
- C:
|
||||
C + UP: jump
|
||||
C + DOWN: menu
|
||||
|
Loading…
Reference in New Issue
Block a user