-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwipeout.html
More file actions
202 lines (166 loc) · 6.59 KB
/
Copy pathwipeout.html
File metadata and controls
202 lines (166 loc) · 6.59 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE HTML>
<!--
Stellar by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Wipeout</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="prism.css">
<script src="prism.js"></script>
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Header -->
<nav class="new-nav">
<ul>
<li><a href="index.html#intro" class="active">About Me</a></li>
<li><a href="index.html#first">Work Experience</a></li>
<li><a href="index.html#second">Projects</a></li>
<li><a href="#footer">Contact Information</a></li>
</ul>
</nav>
<!-- Main -->
<div class="project-page-background">
<!-- Content -->
<section class="main">
<h1 class="project-page-title">Wipeout - Godot/C++</h1>
<h2 class="project-page-subtitle">Gameplay</h2>
<iframe class="image vid"
src="https://www.youtube.com/embed/QlupLVCiuCc">
</iframe>
<h2 class="project-page-subtitle">Overview</h2>
<ul class="project-page-subtitle">
<li>Designed and created an obstacle course in Godot with 4 different obstacles</li>
<li>Implemented scripts in C++ to animate the obstacle course and detect when the player has won</li>
<li>Designed and implemented a networked multiplayer system that supports up to 2 players</li>
</ul>
<h2 class="project-page-subtitle">Code Snippets</h2>
<button class="collapsible">Win Detection</button>
<!-- Code Snippet -->
<div class="content" style="display: none;"><pre class="line-numbers"><code class="language-clike">#include "trophy.h"
#include <SceneTree.hpp>
using namespace godot;
void Trophy::_register_methods() {
register_method("_area_entered", &Trophy::_area_entered);
register_method("_ready", &Trophy::_ready);
}
void Trophy::_init() {
start = 0;
}
// Constructor for Trophy Object
Trophy::Trophy() {
}
// Destructor for Trophy Object
Trophy::~Trophy() {
}
// Intializer for the Trophy class
void Trophy::_ready()
{
audioNode = get_node("VictorySoundPlayer");
areaNode = get_node("Area");
area = godot::Object::cast_to<Area>(areaNode);
audioPlayer = godot::Object::cast_to<AudioStreamPlayer>(audioNode);
// Connects area object with body_entered signal
area->connect("body_entered", this, "_area_entered");
}
// Function that triggers once the Trophy's area is entered
void Trophy::_area_entered() {
Godot::print("CollisionDetected");
// Plays the audio only on the first collision
if (start == 1)
{
if (audioPlayer)
{
audioPlayer->play();
}
// Change the scene to the game over scene
get_tree()->change_scene("res://main_scenes/GameoverScreen.tscn");
}
start += 1;
}</code></pre></div>
<button class="collapsible">Networking Code</button>
<!-- Code Snippet -->
<div class="content" style="display: none;"><pre class="line-numbers"><code class="language-clike">void GameManager::_host_start() {
// Creates and sets the server
network = NetworkedMultiplayerENet::_new();
network->create_server(port, max_players);
get_tree()->set_network_peer(network);
// Connects network signals to defined functions
network->connect("peer_connected", this, "_player_connected");
network->connect("peer_disconnected", this, "_player_disconnected");
// Stores clients name with network ID in the dictionary
local_player_id = get_tree()->get_network_unique_id();
player_names[0] = current_player_name;
//TEST Print statement
Godot::print("Server started!");
}
void GameManager::_player_connected(int player_id) {
Godot::print("Player connected!");
}
void GameManager::_player_disconnected(int player_id) {
Godot::print("Player disconnected!");
Node* player2 = get_tree()->get_root()->get_node("Player2");
if (player2)
{
get_tree()->get_root()->remove_child(player2);
}
else
{
Godot::print("Player2 node is null in game manager");
}
}
void GameManager::_send_player_info(int client_id, String client_name) {
player_names[1] = client_name;
rpc("_update_player_names", player_names[0], player_names[1]);
rpc("_update_waiting_room");
}
void GameManager::_client_start() {
// Creates and sets the client
network = NetworkedMultiplayerENet::_new();
network->create_client("127.0.0.1", port);
get_tree()->set_network_peer(network);
player_ids[1] = get_tree()->get_network_unique_id();
// Connects network signals to defined functions
get_tree()->connect("connection_failed", this, "_connected_fail");
get_tree()->connect("server_disconnected", this, "_server_disconnected");
get_tree()->connect("connected_to_server", this, "_connected_ok");
//TEST Print statement
Godot::print("...Attempting to join server...");
}</code></pre></div>
</section>
</div>
<!-- Footer -->
<footer id="footer">
<section>
<h2>Contact information</h2>
<dl class="alt">
<dt>Linkedin</dt>
<a href="https://www.linkedin.com/in/dani-amir/"><dd>https://www.linkedin.com/in/dani-amir/</dd></a>
<dt>Email</dt>
<dd><a href="#">daniamir2001@yahoo.com</a></dd>
</dl>
<ul class="icons">
<li><a href="https://github.com/Htmlpro19/" class="icon brands fa-github alt"><span class="label">GitHub</span></a></li>
<li><a href="https://www.linkedin.com/in/dani-amir/" class="icon brands fa-linkedin alt"><span class="label">Linkedin</span></a></li>
</ul>
</section>
<p class="copyright">© Dani Amir. Design: <a href="https://html5up.net">HTML5 UP</a>.</p>
</footer>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.scrollex.min.js"></script>
<script src="assets/js/jquery.scrolly.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>