Skip to content

Commit ef62ca6

Browse files
author
Allen Ray
committed
some community examples
1 parent 74768b6 commit ef62ca6

File tree

21 files changed

+85
-84
lines changed

21 files changed

+85
-84
lines changed

community/bouncing/bouncing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ func run() {
4949
}()
5050

5151
for !win.Closed() {
52-
win.SetClosed(win.JustPressed(opengl.KeyEscape) || win.JustPressed(opengl.KeyQ))
52+
win.SetClosed(win.JustPressed(pixel.KeyEscape) || win.JustPressed(pixel.KeyQ))
5353

54-
if win.JustPressed(opengl.KeySpace) {
54+
if win.JustPressed(pixel.KeySpace) {
5555
for _, ball := range balls {
5656
ball.color = ball.palette.next()
5757
}
5858
}
5959

60-
if win.JustPressed(opengl.KeyEnter) {
60+
if win.JustPressed(pixel.KeyEnter) {
6161
for _, ball := range balls {
6262
ball.pos = center()
6363
ball.vel = randomVelocity()

community/go-jetpack/jetpack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ func run() {
121121
win.Clear(colornames.Green)
122122

123123
// Jetpack - Controls
124-
jetpackOn = win.Pressed(opengl.KeyUp) || win.Pressed(opengl.KeyW)
124+
jetpackOn = win.Pressed(pixel.KeyUp) || win.Pressed(pixel.KeyW)
125125

126-
if win.Pressed(opengl.KeyRight) || win.Pressed(opengl.KeyD) {
126+
if win.Pressed(pixel.KeyRight) || win.Pressed(pixel.KeyD) {
127127
jetpackOn = true
128128
flipped = -1
129129
radians -= tilt
130130
velX += tilt * 30
131-
} else if win.Pressed(opengl.KeyLeft) || win.Pressed(opengl.KeyA) {
131+
} else if win.Pressed(pixel.KeyLeft) || win.Pressed(pixel.KeyA) {
132132
jetpackOn = true
133133
flipped = 1
134134
radians += tilt

community/gophermark/gophermark.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ func run() {
9595
}
9696

9797
last := time.Now()
98-
for !win.Closed() && !win.JustPressed(opengl.KeyEscape) {
98+
for !win.Closed() && !win.JustPressed(pixel.KeyEscape) {
9999
dt := time.Since(last).Seconds()
100100
last = time.Now()
101101

102-
if win.Pressed(opengl.MouseButtonLeft) {
102+
if win.Pressed(pixel.MouseButtonLeft) {
103103
mouse := win.MousePosition()
104104
for i := 0; i < 10; i++ {
105105
gophers = append(gophers, newGopher(mouse))

community/line-collisions/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ func run() {
4242
imd.Clear()
4343

4444
// When mouse left-click, move the rectangle so its' center is at the mouse position
45-
if win.JustPressed(opengl.MouseButtonLeft) {
45+
if win.JustPressed(pixel.MouseButtonLeft) {
4646
rectToMouse := r.Center().To(win.MousePosition())
4747
r = r.Moved(rectToMouse)
4848
}
4949

5050
// When mouse right-click, set either the beginning or end of the line.
51-
if win.JustPressed(opengl.MouseButtonRight) {
51+
if win.JustPressed(pixel.MouseButtonRight) {
5252
if clickLine == clickLineA {
5353
// Set the beginning of the line to the mouse position.
5454
// To make it clearer to the user, set the end position 1 pixel (in each direction) away from the first

community/maze/maze-generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func run() {
231231
gridIMDraw := imdraw.New(nil)
232232

233233
for !win.Closed() {
234-
if win.JustReleased(opengl.KeyR) {
234+
if win.JustReleased(pixel.KeyR) {
235235
fmt.Println("R pressed")
236236
grid, backTrackStack, currentCell = setupMaze(cols, rows)
237237
}

community/procedural-terrain-1d/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func run() {
5757
drawTerrain(win, imd)
5858

5959
for !win.Closed() {
60-
if win.JustPressed(opengl.KeySpace) {
60+
if win.JustPressed(pixel.KeySpace) {
6161
drawTerrain(win, imd)
6262
}
6363
win.Update()

community/raycaster/raycaster.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func run() {
373373
mapRot := -1.6683362599999894
374374

375375
for !win.Closed() {
376-
if win.JustPressed(opengl.KeyEscape) || win.JustPressed(opengl.KeyQ) {
376+
if win.JustPressed(pixel.KeyEscape) || win.JustPressed(pixel.KeyQ) {
377377
return
378378
}
379379

@@ -384,67 +384,67 @@ func run() {
384384

385385
as = getActionSquare()
386386

387-
if win.Pressed(opengl.KeyUp) || win.Pressed(opengl.KeyW) {
387+
if win.Pressed(pixel.KeyUp) || win.Pressed(pixel.KeyW) {
388388
moveForward(3.5 * dt)
389389
}
390390

391-
if win.Pressed(opengl.KeyA) {
391+
if win.Pressed(pixel.KeyA) {
392392
moveLeft(3.5 * dt)
393393
}
394394

395-
if win.Pressed(opengl.KeyDown) || win.Pressed(opengl.KeyS) {
395+
if win.Pressed(pixel.KeyDown) || win.Pressed(pixel.KeyS) {
396396
moveBackwards(3.5 * dt)
397397
}
398398

399-
if win.Pressed(opengl.KeyD) {
399+
if win.Pressed(pixel.KeyD) {
400400
moveRight(3.5 * dt)
401401
}
402402

403-
if win.Pressed(opengl.KeyRight) {
403+
if win.Pressed(pixel.KeyRight) {
404404
turnRight(1.2 * dt)
405405
}
406406

407-
if win.Pressed(opengl.KeyLeft) {
407+
if win.Pressed(pixel.KeyLeft) {
408408
turnLeft(1.2 * dt)
409409
}
410410

411-
if win.JustPressed(opengl.KeyM) {
411+
if win.JustPressed(pixel.KeyM) {
412412
showMap = !showMap
413413
}
414414

415-
if win.JustPressed(opengl.Key1) {
415+
if win.JustPressed(pixel.Key1) {
416416
as.set(1)
417417
}
418418

419-
if win.JustPressed(opengl.Key2) {
419+
if win.JustPressed(pixel.Key2) {
420420
as.set(2)
421421
}
422422

423-
if win.JustPressed(opengl.Key3) {
423+
if win.JustPressed(pixel.Key3) {
424424
as.set(3)
425425
}
426426

427-
if win.JustPressed(opengl.Key4) {
427+
if win.JustPressed(pixel.Key4) {
428428
as.set(4)
429429
}
430430

431-
if win.JustPressed(opengl.Key5) {
431+
if win.JustPressed(pixel.Key5) {
432432
as.set(5)
433433
}
434434

435-
if win.JustPressed(opengl.Key6) {
435+
if win.JustPressed(pixel.Key6) {
436436
as.set(6)
437437
}
438438

439-
if win.JustPressed(opengl.Key7) {
439+
if win.JustPressed(pixel.Key7) {
440440
as.set(7)
441441
}
442442

443-
if win.JustPressed(opengl.Key0) {
443+
if win.JustPressed(pixel.Key0) {
444444
as.set(0)
445445
}
446446

447-
if win.JustPressed(opengl.KeySpace) {
447+
if win.JustPressed(pixel.KeySpace) {
448448
as.toggle(3)
449449
}
450450

community/starfield/starfield.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ func run() {
9393
last := time.Now()
9494

9595
for !win.Closed() {
96-
win.SetClosed(win.JustPressed(opengl.KeyEscape) || win.JustPressed(opengl.KeyQ))
96+
win.SetClosed(win.JustPressed(pixel.KeyEscape) || win.JustPressed(pixel.KeyQ))
9797

98-
if win.Pressed(opengl.KeyUp) {
98+
if win.Pressed(pixel.KeyUp) {
9999
speed += 10
100100
}
101101

102-
if win.Pressed(opengl.KeyDown) {
102+
if win.Pressed(pixel.KeyDown) {
103103
if speed > 10 {
104104
speed -= 10
105105
}
106106
}
107107

108-
if win.Pressed(opengl.KeySpace) {
108+
if win.Pressed(pixel.KeySpace) {
109109
speed = 100
110110
}
111111

community/sudoku/sudoku.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func run() {
114114
}
115115

116116
// select a box
117-
if win.JustPressed(opengl.MouseButtonLeft) {
117+
if win.JustPressed(pixel.MouseButtonLeft) {
118118
if input {
119119
imd.Clear()
120120
}
@@ -132,35 +132,35 @@ func run() {
132132
}
133133
// act on user input
134134
if input && !mask[x][y] {
135-
if win.JustPressed(opengl.Key1) || win.JustPressed(opengl.KeyKP1) {
135+
if win.JustPressed(pixel.Key1) || win.JustPressed(pixel.KeyKP1) {
136136
updateBoard(1, imd)
137137
}
138-
if win.JustPressed(opengl.Key2) || win.JustPressed(opengl.KeyKP2) {
138+
if win.JustPressed(pixel.Key2) || win.JustPressed(pixel.KeyKP2) {
139139
updateBoard(2, imd)
140140
}
141-
if win.JustPressed(opengl.Key3) || win.JustPressed(opengl.KeyKP3) {
141+
if win.JustPressed(pixel.Key3) || win.JustPressed(pixel.KeyKP3) {
142142
updateBoard(3, imd)
143143
}
144-
if win.JustPressed(opengl.Key4) || win.JustPressed(opengl.KeyKP4) {
144+
if win.JustPressed(pixel.Key4) || win.JustPressed(pixel.KeyKP4) {
145145
updateBoard(4, imd)
146146
}
147-
if win.JustPressed(opengl.Key5) || win.JustPressed(opengl.KeyKP5) {
147+
if win.JustPressed(pixel.Key5) || win.JustPressed(pixel.KeyKP5) {
148148
updateBoard(5, imd)
149149
}
150-
if win.JustPressed(opengl.Key6) || win.JustPressed(opengl.KeyKP6) {
150+
if win.JustPressed(pixel.Key6) || win.JustPressed(pixel.KeyKP6) {
151151
updateBoard(6, imd)
152152
}
153-
if win.JustPressed(opengl.Key7) || win.JustPressed(opengl.KeyKP7) {
153+
if win.JustPressed(pixel.Key7) || win.JustPressed(pixel.KeyKP7) {
154154
updateBoard(7, imd)
155155
}
156-
if win.JustPressed(opengl.Key8) || win.JustPressed(opengl.KeyKP8) {
156+
if win.JustPressed(pixel.Key8) || win.JustPressed(pixel.KeyKP8) {
157157
updateBoard(8, imd)
158158
}
159-
if win.JustPressed(opengl.Key9) || win.JustPressed(opengl.KeyKP9) {
159+
if win.JustPressed(pixel.Key9) || win.JustPressed(pixel.KeyKP9) {
160160
updateBoard(9, imd)
161161
}
162-
if win.JustPressed(opengl.Key0) || win.JustPressed(opengl.KeyKP0) ||
163-
win.JustPressed(opengl.KeyBackspace) || win.JustPressed(opengl.KeySpace) {
162+
if win.JustPressed(pixel.Key0) || win.JustPressed(pixel.KeyKP0) ||
163+
win.JustPressed(pixel.KeyBackspace) || win.JustPressed(pixel.KeySpace) {
164164
updateBoard(0, imd)
165165
}
166166
}

community/tilemap/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ func gameloop(win *opengl.Window, tilemap *tmx.Map) {
4848
// Camera movement
4949
cam := pixel.IM.Scaled(camPos, camZoom).Moved(win.Bounds().Center().Sub(camPos))
5050
win.SetMatrix(cam)
51-
if win.Pressed(opengl.KeyLeft) {
51+
if win.Pressed(pixel.KeyLeft) {
5252
camPos.X -= camSpeed * dt
5353
}
54-
if win.Pressed(opengl.KeyRight) {
54+
if win.Pressed(pixel.KeyRight) {
5555
camPos.X += camSpeed * dt
5656
}
57-
if win.Pressed(opengl.KeyDown) {
57+
if win.Pressed(pixel.KeyDown) {
5858
camPos.Y -= camSpeed * dt
5959
}
60-
if win.Pressed(opengl.KeyUp) {
60+
if win.Pressed(pixel.KeyUp) {
6161
camPos.Y += camSpeed * dt
6262
}
6363
camZoom *= math.Pow(camZoomSpeed, win.MouseScroll().Y)

0 commit comments

Comments
 (0)