Skip to content

Commit 4c866e6

Browse files
committed
small polishes
1 parent f63934d commit 4c866e6

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

projects/build-a-conversational-game-in-p5js/build-a-conversational-game-in-p5js.mdx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ tags:
3333
uid={true}
3434
/>
3535

36-
**Prerequisites**: p5.js, JavaScript
37-
**Version**: p5@1.11.2, JavaScript ES2023
38-
**Read Time**: 30 minutes
36+
**Prerequisites**: p5.js, JavaScript
37+
**Version**: p5 1.11.2
38+
**Read Time**: 30 minutes
3939

4040
## Introduction
4141

@@ -88,10 +88,12 @@ Hi, my name is ✨Julien✨, and I’m the new Senior Curriculum Developer here
8888
</p>
8989
</div>
9090

91-
Since this is my first project tutorial here at Codédex, I’m revisiting the first coding project I ever finished. I made it ten years ago using [Processing](https://processing.org) (the Java-based precursor to p5.js).
91+
Since this is my first project tutorial here at Codédex, I’m revisiting the first coding project I ever finished. I made it ten years ago using [Processing](https://processing.org) (the Java-based precursor to the p5.js library).
9292

9393
## A Conversation
9494

95+
Here's the project:
96+
9597
The game is called *A Conversation*, and it’s a two-player game of Pong, but with a twist. Instead of each paddle, I drew a person’s head facing toward the center, and instead of a ball, I drew a speech bubble. As players hit the speech bubble back and forth, the text inside the speech bubble changes to form a conversation.
9698

9799
<RoundedImage
@@ -117,11 +119,11 @@ I spent a lot of 2014 thinking about the ways people communicate nonverbally whi
117119
The conversation itself was…hm…it was pretty dramatic. I wasn’t sure if I was going to make this tutorial, because I was a little embarrassed by the narrative stylings of nineteen-year-old Julien. But honestly? I think it’s important to honor our past selves. I was learning to code for the first time after a lifetime of considering myself An Artist Not A Programmer.
118120

119121
<RoundedImage
120-
link="https://i.imgur.com/cA4UduS.png"
122+
link="https://i.imgur.com/XyJaet1.png"
121123
description=""
122124
/>
123125

124-
<div style={{ textAlign: "center" }}>
126+
<div style={{ textAlign: "center"}}>
125127
[@WarronBebster](https://x.com/warronbebster)
126128
</div>
127129

@@ -136,7 +138,7 @@ I found this email to my community college professor where I gave her some conte
136138
description=""
137139
/>
138140

139-
Omg,,,,
141+
Omg....
140142
Anyway, let’s dive in!
141143

142144

@@ -157,7 +159,7 @@ For this year’s iteration of Pong, I decided to have a conversation with my pa
157159

158160
### Upgrading From Simple Pong
159161

160-
There were a few elements I added to upgrade the sketch from the WASD (Pong) exercise in our p5.js tutorial. Here is a link to the [Codédex Exercise](https://www.codedex.io/p5js/05-wasd) that features single-player Pong. Here is the [starter code](https://www.codedex.io/@Julien/build/pong-as-a-conversation-starter-code) for a basic two-player pong game, which looks a bit different from the Codédex exercise.
162+
There were a few elements I added to upgrade the sketch from the WASD (Pong) exercise in our p5.js tutorial. Here is a link to the [Codédex exercise](https://www.codedex.io/p5js/05-wasd) that features single-player Pong. Here is the [starter code](https://www.codedex.io/@Julien/build/pong-as-a-conversation-starter-code) for a basic two-player pong game, which looks a bit different from the Codédex exercise.
161163

162164
<RoundedImage
163165
link="https://i.imgur.com/leVbTL9.gif"
@@ -168,11 +170,11 @@ There were a few elements I added to upgrade the sketch from the WASD (Pong) exe
168170

169171
So, how do we go from a screensaver to a conversation? I find it helpful to break down the process into smaller steps. I’m gonna show you three things that can personalize our basic Pong game. 🕹️
170172

171-
🎧**Step 1: Add a looping soundtrack**
173+
🎧 **Step 1: Add a looping soundtrack**
172174

173-
The first thing I want to do is add a soundtrack, to give the game ambiance. To play sound files in p5.js in the Codédex IDE, you’ll need to link to a url containing a .ogg audio file. You can find a ton of .ogg files with varying moods [here](https://developers.google.com/assistant/tools/sound-library). I chose an ambient outdoor summer track since I’ve always loved laying in the grass while reading a book in the park!
175+
The first thing I want to do is add a soundtrack, to give the game ambiance. To play sound files in p5.js in the Codédex IDE, you’ll need to link to a url containing a **.ogg** audio file. You can find a ton of .ogg files with varying moods [here](https://developers.google.com/assistant/tools/sound-library). I chose an ambient outdoor summer track since I’ve always loved laying in the grass while reading a book in the park!
174176

175-
Declare a `gameSoundtrack` variable and define it in the preload function, where audio (and images!) load before the setup function.
177+
Declare a `gameSoundtrack` variable and define it in the preload function, where audio (and images!) load before the `setup()` function.
176178

177179
```js
178180
let gameSoundtrack;
@@ -193,7 +195,7 @@ function setup(){
193195
}
194196
```
195197

196-
🕺🏻**Step 2: Replace paddles with player images**
198+
🕺🏻 **Step 2: Replace paddles with player images**
197199

198200
To add images for the players, you’ll need to draw or find transparent PNGs. Since I decided to have a conversation with my younger self this time, I found a recent photo of me posing in a way that’s similar to a photo of me posing as a kid. Then, I removed their backgrounds with [Adobe’s Free Image Background Remover](https://www.adobe.com/express/feature/image/remove-background) and did some light editing in Adobe Express.
199201

@@ -231,7 +233,7 @@ function preload() {
231233
}
232234
```
233235

234-
I replaced the paddle rectangles with images in the showPaddle function.
236+
I replaced the paddle rectangles with images in the `showPaddle()` function.
235237

236238
```js
237239
function showPaddle(playerNumber){
@@ -283,8 +285,9 @@ In the `drawGame()` function, I draw the text, and position it with the ball coo
283285
textSize(20);
284286
fill(255);
285287
textAlign(CENTER);
288+
286289
if (showBall == true){
287-
text(convoText[phrase], ball.h, ball.v);
290+
text(convoText[phrase], ball.h, ball.v);
288291
}
289292
pop();
290293
```
@@ -294,7 +297,7 @@ In the `moveBall()` function, I cycle through the text array each time the ball
294297
```js
295298
...
296299
phrase++;
297-
//stop the array at the last phrase
300+
// stop the array at the last phrase
298301
if (phrase == convoText.length) {
299302
phrase = 0;
300303
}

0 commit comments

Comments
 (0)