-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
61 lines (51 loc) · 1.33 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include <random>
#include <time.h>
#include "MyWindow.h"
#include "Game.h"
#include "MainMenu.h"
#include "constants.h"
// Screen dimension constants
const int SCREEN_WIDTH = 720;
const int SCREEN_HEIGHT = 480;
int main(int argc, char *args[])
{
srand(time(0));
std::string serverIp = "192.168.227.102";
if (argc > 1)
{
serverIp = args[1];
}
int sockfd;
// struct sockaddr_in myAddr;
struct sockaddr_in theirAddr;
char buf[512];
char recBuf[512];
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror("socket creation failed");
}
fcntl(sockfd, F_SETFL, O_NONBLOCK);
// memset(&myAddr, 0, sizeof(myAddr));
memset(&theirAddr, 0, sizeof(theirAddr));
// myAddr.sin_family = AF_INET; // IPv4
// myAddr.sin_addr.s_addr = INADDR_ANY;
// myAddr.sin_port = htons(2000);
theirAddr.sin_family = AF_INET;
theirAddr.sin_port = htons(8080);
// theirAddr.sin_addr.s_addr = INADDR_ANY;
inet_pton(AF_INET, serverIp.c_str(), &(theirAddr.sin_addr.s_addr));
// Start up SDL and create window
LWindow window(SCREEN_WIDTH, SCREEN_HEIGHT);
// LGame myGame(window);
// window.setCurrScreen(&myGame);
MainMenu *mainMenu = new MainMenu(window, sockfd, theirAddr);
window.setCurrScreen(mainMenu);
window.begin();
close(sockfd);
return 0;
}