added new screens and getting ready for networking, looking at SDL_net for cross platfrom networking so i dont have to touch windows
This commit is contained in:
1042
include/SDL_net.h
Normal file
1042
include/SDL_net.h
Normal file
File diff suppressed because it is too large
Load Diff
94
include/SDLnetsys.h
Normal file
94
include/SDLnetsys.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
SDL_net: An example cross-platform network library for use with SDL
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* Include normal system headers */
|
||||
#if defined(__APPLE__) && !defined(_DARWIN_C_SOURCE)
|
||||
#define _DARWIN_C_SOURCE
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__OS2__) && !defined(__EMX__)
|
||||
#include <nerrno.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* Include system network headers */
|
||||
#if defined(__WIN32__) || defined(WIN32)
|
||||
#define __USE_W32_SOCKETS
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <iphlpapi.h>
|
||||
#else /* UNIX */
|
||||
#ifdef __OS2__
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h>
|
||||
#ifndef __BEOS__
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __OS2__
|
||||
typedef int socklen_t;
|
||||
#elif 0
|
||||
/* FIXME: What platforms need this? */
|
||||
typedef Uint32 socklen_t;
|
||||
#endif
|
||||
|
||||
/* System-dependent definitions */
|
||||
#ifndef __USE_W32_SOCKETS
|
||||
#ifdef __OS2__
|
||||
#define closesocket soclose
|
||||
#else /* !__OS2__ */
|
||||
#define closesocket close
|
||||
#endif /* __OS2__ */
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#endif /* __USE_W32_SOCKETS */
|
||||
|
||||
#ifdef __USE_W32_SOCKETS
|
||||
#define SDLNet_GetLastError WSAGetLastError
|
||||
#define SDLNet_SetLastError WSASetLastError
|
||||
#ifndef EINTR
|
||||
#define EINTR WSAEINTR
|
||||
#endif
|
||||
#else
|
||||
int SDLNet_GetLastError(void);
|
||||
void SDLNet_SetLastError(int err);
|
||||
#endif
|
||||
|
||||
22
include/battle.h
Normal file
22
include/battle.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//Troy Rosin
|
||||
|
||||
#ifndef __battle_h__
|
||||
#define __battle_h__
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#define GRID_SPACING 4
|
||||
|
||||
#define BATTLE_COLS 7
|
||||
#define BATTLE_ROWS 6
|
||||
|
||||
SDL_Rect *battle_rows[BATTLE_ROWS];
|
||||
SDL_Rect enemy_backrow[BATTLE_COLS];
|
||||
SDL_Rect enemy_frontrow[BATTLE_COLS];
|
||||
|
||||
SDL_Rect friendly_frontrow[BATTLE_COLS];
|
||||
SDL_Rect friendly_midrow[BATTLE_COLS];
|
||||
SDL_Rect friendly_backrow[BATTLE_COLS];
|
||||
SDL_Rect friendly_farrow[BATTLE_COLS];
|
||||
|
||||
#endif
|
||||
53
include/chat.h
Normal file
53
include/chat.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
CHAT: A chat client/server using the SDL example network library
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Convert four letters into a number */
|
||||
#define MAKE_NUM(A, B, C, D) (((A+B)<<8)|(C+D))
|
||||
|
||||
/* Defines for the chat client */
|
||||
#define CHAT_SCROLLBACK 512 /* Save 512 lines in scrollback */
|
||||
#define CHAT_PROMPT "> "
|
||||
#define CHAT_PACKETSIZE 256 /* Maximum length of a message */
|
||||
|
||||
/* Defines shared between the server and client */
|
||||
#define CHAT_PORT MAKE_NUM('C','H','A','T')
|
||||
|
||||
/* The protocol between the chat client and server */
|
||||
#define CHAT_HELLO 0 /* 0+Port+len+name */
|
||||
#define CHAT_HELLO_PORT 1
|
||||
#define CHAT_HELLO_NLEN CHAT_HELLO_PORT+2
|
||||
#define CHAT_HELLO_NAME CHAT_HELLO_NLEN+1
|
||||
#define CHAT_ADD 1 /* 1+N+IP+Port+len+name */
|
||||
#define CHAT_ADD_SLOT 1
|
||||
#define CHAT_ADD_HOST CHAT_ADD_SLOT+1
|
||||
#define CHAT_ADD_PORT CHAT_ADD_HOST+4
|
||||
#define CHAT_ADD_NLEN CHAT_ADD_PORT+2
|
||||
#define CHAT_ADD_NAME CHAT_ADD_NLEN+1
|
||||
#define CHAT_DEL 2 /* 2+N */
|
||||
#define CHAT_DEL_SLOT 1
|
||||
#define CHAT_DEL_LEN CHAT_DEL_SLOT+1
|
||||
#define CHAT_BYE 255 /* 255 */
|
||||
#define CHAT_BYE_LEN 1
|
||||
|
||||
/* The maximum number of people who can talk at once */
|
||||
#define CHAT_MAXPEOPLE 10
|
||||
@@ -9,6 +9,32 @@
|
||||
#define CARD_SIZE (128 * 2)
|
||||
#define CARD_W (96 * 2)
|
||||
|
||||
#define MAX_CARDS 1 << 8
|
||||
#define MAX_EFFECTS 4
|
||||
#define MAX_ENCHANTS 4
|
||||
#define MAX_NAME 64
|
||||
|
||||
#define R_COMMON 1
|
||||
#define R_UNCOMMON 2
|
||||
#define R_RARE 3
|
||||
#define R_ANCIENT 4
|
||||
#define R_MYTHICAL 5
|
||||
#define R_DEVINE 6
|
||||
|
||||
|
||||
typedef struct crd
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
int effect[MAX_EFFECTS];
|
||||
int enchants[MAX_ENCHANTS];
|
||||
int rarity;
|
||||
int set;
|
||||
int type;
|
||||
char *explination;
|
||||
char name[MAX_NAME];
|
||||
struct crd *next;
|
||||
} CARD;
|
||||
|
||||
typedef struct hand
|
||||
{
|
||||
int handsize;
|
||||
@@ -17,6 +43,21 @@ typedef struct hand
|
||||
} HAND;
|
||||
|
||||
|
||||
typedef struct discard_pile
|
||||
{
|
||||
CARD *bot;
|
||||
CARD *top;
|
||||
int count;
|
||||
CARD cards[MAX_CARDS];
|
||||
} D_PILE;
|
||||
|
||||
typedef struct dck
|
||||
{
|
||||
int count;
|
||||
CARD *bot;
|
||||
CARD *top;
|
||||
} DECK;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
19
include/err_check.h
Normal file
19
include/err_check.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//Troy Rosin
|
||||
|
||||
#ifndef __err_check_h__
|
||||
#define __err_check_h__
|
||||
|
||||
//pass TEX is an SDL_Texture pointer, rend is the renderer
|
||||
// and path is the path to the texture to load.
|
||||
|
||||
#define IMG_GETANDCHECK(TEX, REND, PATH)\
|
||||
TEX = IMG_LoadTexture(REND, PATH);\
|
||||
if(!TEX){\
|
||||
printf("IMG_LoadTexture error: %s\n", IMG_GetError());\
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,27 +6,20 @@
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
|
||||
#define DEF_WINDOW_WIDTH 1920
|
||||
#define DEF_WINDOW_HEIGHT 1080
|
||||
|
||||
|
||||
extern int running;
|
||||
extern int state;
|
||||
|
||||
#define TITLE 0
|
||||
#define BATTLE 1
|
||||
#define START 1
|
||||
#define HOST 2
|
||||
#define JOIN 3
|
||||
#define OPTIONS 4
|
||||
#define BATTLE 5
|
||||
#define OVERWORLD 6
|
||||
extern int state;
|
||||
|
||||
#define START_GAME 0
|
||||
#define EXIT_GAME 1
|
||||
#define MAIN_SELECTIONS 2
|
||||
extern int selected_index;
|
||||
|
||||
void start_battle();
|
||||
|
||||
extern SDL_Window* window;
|
||||
extern SDL_Renderer* renderer;
|
||||
extern SDL_Event event;
|
||||
void start_game();
|
||||
void show_options();
|
||||
void host_game();
|
||||
void join_game();
|
||||
|
||||
#define GRAB_NEW 2
|
||||
#define GRAB_OLD 1
|
||||
@@ -34,4 +27,9 @@ extern SDL_Event event;
|
||||
#define NOT_DRAG 0
|
||||
extern int dragging;
|
||||
|
||||
|
||||
#define MAX_NAMESZ 64
|
||||
#define MAX_PLAYERS 4
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
17
include/host.h
Normal file
17
include/host.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//Troy Rosin
|
||||
#ifndef __host_h__
|
||||
#define __host_h__
|
||||
|
||||
#define NO_OBJECT 0
|
||||
#define SET_NAME_BUTTON 1
|
||||
#define START_GAME_BUTTON 2
|
||||
|
||||
extern int over_object;
|
||||
|
||||
char *get_this_name(int i);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
29
include/main.h
Normal file
29
include/main.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//Troy Rosin
|
||||
|
||||
#ifndef __main_h__
|
||||
#define __main_h__
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#define DEF_WINDOW_WIDTH 1920
|
||||
#define DEF_WINDOW_HEIGHT 1080
|
||||
|
||||
|
||||
|
||||
extern int running;
|
||||
extern int state;
|
||||
|
||||
#define START_GAME 0
|
||||
#define HOST_GAME 1
|
||||
#define JOIN_GAME 2
|
||||
#define OPTIONS_MENU 3
|
||||
#define EXIT_GAME 4
|
||||
#define MAIN_SELECTIONS 5
|
||||
extern int selected_index;
|
||||
|
||||
|
||||
extern SDL_Window* window;
|
||||
extern SDL_Renderer* renderer;
|
||||
extern SDL_Event event;
|
||||
|
||||
#endif
|
||||
11
include/net.h
Normal file
11
include/net.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//Troy Rosin
|
||||
|
||||
#ifndef __netcode_h__
|
||||
#define __netcode_h__
|
||||
|
||||
#define PORT 36911
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
22
include/overworld.h
Normal file
22
include/overworld.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//Troy Rosin
|
||||
|
||||
#ifndef __overworld_h__
|
||||
#define __overworld_h__
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
void start_overworld();
|
||||
|
||||
|
||||
#define OW_GRIDSZ 128
|
||||
|
||||
typedef struct player
|
||||
{
|
||||
SDL_Point pos;
|
||||
SDL_Texture *texture;
|
||||
} PLAYER;
|
||||
|
||||
PLAYER *get_this_player();
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user