Attributions
Usage is attributed in the speaker notes
1
Please do not redistribute these slides without prior written permission
2
CS 5500
Foundations of Software Engineering
Dr. Mike Shah
3
Pre-Class Warm up (1/4)
4
Pre-Class Warm up (2/4)
5
Pre-Class Warm up (3/4)
6
Pre-Class Warm up (4/4)
7
Note to self: Start audio recording of lecture :)�(Someone remind me if I forget!)
8
“The Daily Scrum”
9
Last Class (“What did I do yesterday”) (1/2)
10
Last Class (“What did I do yesterday”) (2/2)
11
Course Logistics (“What are we going to do today”)
12
Blocking (“What is stopping forward progress”)
13
Getting Organized on our project
14
Husky Town - Base Requirements (1/2)
15
Husky Town - Base Requirements (2/2)
16
2D TileMaps
Tilemap Demo (1/2)
18
Tilemap Demo (2/2)
19
Tiled 2D Applications
20
2D Tile Maps
Square 2D Tile maps
Tilemap atlas (1/3)
Texture Atlas of many tiles
2D Tile map which references a texture atlas
Tilemap atlas (2/3)
00
01
02
03
04
...
2D Tile map which references a texture atlas
Texture Atlas of many tiles
Tilemap atlas (3/3)
00
01
02
03
04
...
2D Tile map which references a texture atlas
Texture Atlas of many tiles
Another example [source] (1/2)
Another example [source] (2/2)
Utilizing Multiple Tile Maps
Layering (Draw Order)
29
Layering (2/3)
30
Layering (3/3)
31
10000
1
1
1
500
-10000
Tilemaps Array Access
32
Picking a Tile from an Atlas (1/3)
00
01
02
03
04
...
7 Columns
Picking a Tile from an Atlas (2/3)
00
01
02
03
04
...
7 Columns
Picking a Tile from an Atlas (3/3)
00
01
02
03
04
...
Col_width = 8
Nice illustration [source]
1D or 2D Arrays Data Structure [row-col-order]
Accessing a 1D array
1D-Array example
Accessing a 1D array
12 Rows
6 Columns
Accessing a 1D array
0
1
2
3
4
5
6
7
8
9
10
11
12
0 1 2 3 4 5
Accessing a 1D array
0 1 2 3 4 5
0
1
2
3
4
5
6
7
8
9
10
11
12
Accessing a 1D array
Here is our target: �x = 3, y = 1
0 1 2 3 4 5
0
1
2
3
4
5
6
7
8
9
10
11
12
Accessing a 1D array
0 1 2 3 (Our x-axis)
Here is our target: �x = 3, y = 1
0
1�our
y-axis
Accessing a 1D array
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0 1 2 3 4 5
0
1
2
3
4
5
6
7
8
9
10
11
12
Accessing a 1D array
This is our ‘pitch or width’
6 is our pitch or ‘width’ or how many column items
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0
1
2
3
4
5
6
7
8
9
10
11
12
Accessing a 1D array
This is what ‘row’ we are on
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0
1
2
3
4
5
6
7
8
9
10
11
12
0 1 2 3 4 5
Accessing a 1D array
y*COLS thus moves us ‘up and down’
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0
1
2
3
4
5
6
7
8
9
10
11
12
0 1 2 3 4 5
Accessing a 1D array
This is what column we are on in our row (i.e. x--coordinate)
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0
1
2
3
4
5
6
7
8
9
10
11
12
0 1 2 3 4 5
Accessing a 1D array
[1 * 6 + 3] = 9 // the 9th tile at (3,1)
Access array like we would on a coordinate system
Here is our target: �x = 3, y = 1
0
1
2
3
4
5
6
7
8
9
10
11
12
0 1 2 3 4 5
Accessing a 1D array
0
1
2
3
4
5
6
7
8
9
10
11
12
A few more examples
0 1 2 3 4 5
Cameras
52
2D Cameras
53
Camera Systems (2/2)
Camera Positioning - Screen Coordinates
0 1 2 3 4 5
6 7 8 9 10 11
12 13 14 15 ...
Camera Positioning - World Coordinates
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
Helper Functions
Tilemap Art Assets
58
Where to get royalty-free art assets?
59
This website had a few nice tilesets:
https://kenney.nl/assets/roguelike-modern-city
You might find others on your own
Some Suggestions
60
Short 5 minute break
61
Husky Town - Base Requirements (2/2)
62
Networking Basics
A crash course into communicating data between processes (on the same or different machines)
63
Networking Crash Course
64
The very basics - Sockets (1/4)
65
The very basics - Sockets (2/4)
66
The very basics - Sockets (3/4)
67
The very basics - Sockets (4/4)
68
If it’s useful analogy--imagine a human as a process, and a tin can as a ‘socket’. The string in between is the ‘network’ where you can listen or send data.
https://w1nnersclub.com/wp-content/uploads/2018/02/tin-can-telephone.jpg
The ‘Network’ and Network Layers
69
Network Programming
70
(FYI) Physical Network Layers
71
Networking Crash Course:
Open Systems Interconnection (OSI)
72
Simplified TCP/IP Model
73
Client-Server Model
A first model to understand networking
https://en.wikipedia.org/wiki/Client%E2%80%93server_model
74
Probably the most popular model is the Client-Server
75
How does communication take place over a socket?
(i.e., what information is being sent)
76
How is information sent?
77
What does an Internet Protocol (IP) do?
78
Example Data Transfer (1/10)
79
Host A has some data
Example Data Transfer (2/10)
80
System call copies data into a kernel buffer
Example Data Transfer (3/10)
81
Data is fit into a packet using some standard protocol
Example Data Transfer (4/10)
82
The entire chunk is called a frame
Example Data Transfer (5/10)
83
LAN copies frame to network
Example Data Transfer (6/10)
84
Router reads frame using its protocol software
Example Data Transfer (7/10)
85
Router finds destination address from packet header
Example Data Transfer (8/10)
86
Router copies data to LAN2 adapter
Example Data Transfer (9/10)
87
Protocol software reads the frame, and strips out payload
Example Data Transfer (10/10)
88
System call is made to read data
Other Issues sending data
89
Data Transmission Protocols
(i.e., TCP and UDP)
90
Internet (Uppercase ‘I’)
91
TCP (Transmission Control Protocol)
92
So per ‘client and server process’, our sockets are using a TCP/IP protocol to send and receive packets of information across the network
UDP (User Datagram Protocol) or (Unreliable Datagram Protocol)
93
TCP versus UDP visual
94
TCP versus UDP
Exercise: What does the audience think -- Pick which protocol may be better in the next slide
95
Should we use UDP or TCP Protocol for the following applications?
96
Should we use UDP or TCP Protocol for the following applications?
97
Should we use UDP or TCP Protocol for the following applications?
98
Another visual of TCP/IP protocol
99
Hardware/Software Organization of Internet Application (1/5)
100
Hardware/Software Organization of Internet Application (2/5)
101
User programs using ‘sockets’ library
Hardware/Software Organization of Internet Application (3/5)
102
System calls are made using TCP/IP protocol
Hardware/Software Organization of Internet Application (4/5)
103
Network adapter takes data (previous diagram)
Hardware/Software Organization of Internet Application (5/5)
104
Reversed process
Programming View of Internet
IP address
105
How we (programmers) view Internet
106
Quick Aside: IPv4 and IPv6
107
Programmer View - IP Addresses
108
Programmer View - Internet Connections (1/2)
109
Programmer View - Internet Connections (2/2)
110
How is the order enforced?
Ans: Based on the protocol
Well-known Service names and ports
111
cat /etc/services | head -n 45
Anatomy of a connection
112
You can use the Port to Identify the services
113
Attempt to talk to the web because the port is 80 (See the 80 at the end after the colon?)
(Aside:) More on portsPort
114
Sockets
Looking again at sockets communication at a low level
115
Sockets Interface
116
Sockets
117
fd suffix means “ file descriptor”
Server + Client Structure (1/7)
118
Server + Client Structure (2/7)
119
Server + Client Structure (3/7)
120
Client launches
Server + Client Structure (4/7)
121
A tcp request is made to connect to a server
Server + Client Structure (5/7)
122
When connected, a data exchange can take place
Server + Client Structure (6/7)
123
Client disconnects when finished
Server + Client Structure (7/7)
124
Server drops client, and can disconnect
C Programmer View - Socket Address Structures
125
Host and Service Conversion: getaddrinfo (1/2)
126
Host and Service Conversion: getaddrinfo (2/2)
127
Host and Service Conversion: getnameinfo
128
Sockets Interface (1/4)
129
Sockets Interface (2/4)
130
Grab address data
Sockets Interface (3/4)
131
Grab address data
Sockets Interface (4/4)
132
Then we can create a socket descriptor
Programmer View - Creating a socket (in C)
133
Sockets Interface (1/5)
134
We created a socket descriptor
Sockets Interface (2/5)
135
Server does the same thing
Sockets Interface (3/5)
136
Server then uses ‘bind’ to associate server’s socket address to a socket descriptor
Sockets Interface (4/5)
137
listen then tells kernel to listen and accept requests from clients.
Sockets Interface (5/5)
138
Now server can ‘accept’ requests, and wait for requests from clients to connect
Short 5 minute break
139
Networking in D
import std.socket;
140
import std.socket;
141
Example socket application
142
Example client/server application (1/3)
143
Example client/server application (2/3)
144
Example client/server application (3/3)
145
Networking Gotcha’s
146
Traps and Pitfalls (1/3)
147
Traps and Pitfalls (2/3)
148
Traps and Pitfalls (3/3)
149
Question to Audience on TCP (1/2)
150
Question to Audience on TCP (2/2)
151
Client-Server Model For Project
152
Should we use UDP or TCP Protocol for the following applications?
153
How to find your IP?
154
Short 5 minute break
155
Retrospective
156
Project Time
157
Daily Wisdom
(Everyday wisdom)
158
Part of Your Project Grade
159
Wisdom on Teamwork! (1/2)
160
Wisdom on Teamwork! (2/2)
161
After teaching this class a few times...
162
After teaching this class a few times...
163
Archetypes (1/3)
164
Archetypes (2/3)
165
Archetypes (3/3)
166
Find your team
167
Action items
168
In-Class Activity
169
In-Class Activity
170
Extra
171
Good Software Engineering
172
Client-Server Model
173
Localhost
174
175
Some more code smells
176
Today we’ll be working in Teams!
177
Lab
178
C++
179
Other means of Networking
i.e., Two common protocols of well known services -- HTTP and FTP
180
HTTP Response and Request
181
FTP (File Transfer Protocol)
182
Networking in SFML
What is available to use in SFML
183
SFML and Networking
184
SFML and Networking
185
SFML Socket API
186
SFML Network Module
187
TCP Socket Example
188
Words to the wise
189