Add descriptions to functions
This commit is contained in:
parent
f6b4a8612c
commit
139ed78464
8
main.go
8
main.go
@ -48,6 +48,7 @@ func windowCollision(player *Player, win pixelgl.Window, dt float64) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Decides what to do with input */
|
||||||
func checkKeys(player *Player, win pixelgl.Window, dt float64) {
|
func checkKeys(player *Player, win pixelgl.Window, dt float64) {
|
||||||
if win.Pressed(pixelgl.KeyLeft) {
|
if win.Pressed(pixelgl.KeyLeft) {
|
||||||
|
|
||||||
@ -83,9 +84,13 @@ func checkKeys(player *Player, win pixelgl.Window, dt float64) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if win.Pressed(pixelgl.KeyDown) {
|
if win.Pressed(pixelgl.KeyDown) {
|
||||||
|
playerDrag(player)
|
||||||
|
playerDrag(player)
|
||||||
|
playerDrag(player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Applies drag to the player */
|
||||||
func playerDrag(player *Player) {
|
func playerDrag(player *Player) {
|
||||||
if player.yV > 0 {
|
if player.yV > 0 {
|
||||||
player.yV -= player.drag
|
player.yV -= player.drag
|
||||||
@ -117,6 +122,7 @@ func playerDrag(player *Player) {
|
|||||||
//return player
|
//return player
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load an image into pixel */
|
||||||
func loadSprite(path string) (pixel.Picture, error) {
|
func loadSprite(path string) (pixel.Picture, error) {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -130,6 +136,7 @@ func loadSprite(path string) (pixel.Picture, error) {
|
|||||||
return pixel.PictureDataFromImage(img), nil
|
return pixel.PictureDataFromImage(img), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apply speed adjustments that have been calculated */
|
||||||
func playerAdjustSpeed(player *Player, dt float64) {
|
func playerAdjustSpeed(player *Player, dt float64) {
|
||||||
player.x += player.xV * dt
|
player.x += player.xV * dt
|
||||||
player.y += player.yV * dt
|
player.y += player.yV * dt
|
||||||
@ -149,6 +156,7 @@ func playerAdjustSpeed(player *Player, dt float64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read a sprite sheet from a pixel.Picture */
|
||||||
func createSpriteSheet(SpriteSheetImg pixel.Picture,
|
func createSpriteSheet(SpriteSheetImg pixel.Picture,
|
||||||
spriteSizeX, spriteSizeY float64) []pixel.Rect {
|
spriteSizeX, spriteSizeY float64) []pixel.Rect {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user