Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Adding GIFs to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryBrownEEngr committed Dec 8, 2023
1 parent c1cf3de commit 42f707d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func turtleRandomWalk(sim models.Scratch) {
}
```

![Golang Scratch simulation of turtle source random walk](https://github.com/GaryBrownEEngr/scratch/blob/main/examples/randomwalk/randomwalk.gif)

### Double Pendulum

Here is a simulation of a double pendulum.
Expand All @@ -93,16 +95,28 @@ Here is a simulation of a double pendulum.
go run github.com/GaryBrownEEngr/scratch/examples/DoublePendulum@latest
```

![Example Picture](https://github.com/GaryBrownEEngr/scratch/blob/main/examples/DoublePendulum/DoublePendulum.gif)
![Golang Scratch simulation of a double pendulum](https://github.com/GaryBrownEEngr/scratch/blob/main/examples/DoublePendulum/DoublePendulum.gif)

### Falling Turtles

Here is a really simple game where you have to click on each turtle before it reaches the bottom of the screen. At the end, your final score is displayed.
This example is a really simple game where you have to click on each turtle before it reaches the bottom of the screen. At the end, your final score is displayed.

```bash
go run github.com/GaryBrownEEngr/scratch/examples/fallingturtles@latest
```

### Tumbler

Here is a simulation of a rotating box filled with circles, boxes, and rounded rectangles. This uses the library github.com/jakecoffman/cp for the physics simulation. The sprites are being drawn using Golang Scratch.

This is a recreation of https://jakecoffman.com/cp-ebiten/tumble/ except without drawing the shapes using ebiten and cp directly. Here, cp is only performing the physics updates. The original code can be found [here](https://github.com/jakecoffman/cp-examples/blob/master/tumble/tumble.go)

```bash
go run github.com/GaryBrownEEngr/scratch/examples/tumbler@latest
```

![Golang Scratch simulation of a rotating box filled with circles, boxes, and rounded rectangles](https://github.com/GaryBrownEEngr/scratch/blob/main/examples/tumbler/tumbler.gif)

## Build Executable

To get the list of go build targets use the following command:
Expand Down
3 changes: 3 additions & 0 deletions examples/randomwalk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func main() {

func simStartFunc(sim models.Scratch) {
sim.AddCostume(sprite.DecodeCodedSprite(sprite.TurtleImage), "t")

// go scratch.CreateGif(sim, time.Millisecond*100, time.Millisecond*100, "./examples/randomwalk/randomwalk.gif", 100)

for {
go turtleRandomWalk(sim)
time.Sleep(time.Millisecond * 500)
Expand Down
Binary file added examples/randomwalk/randomwalk.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion examples/tumbler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// https://github.com/jakecoffman/cp-ebiten/tree/gh-pages
func main() {
params := scratch.ScratchParams{Width: 1000, Height: 1000, ShowFPS: true}
params := scratch.ScratchParams{Width: 600, Height: 600, ShowFPS: true}
scratch.Start(params, simStartFunc)
}

Expand Down Expand Up @@ -65,6 +65,8 @@ func simStartFunc(sim models.Scratch) {
}
}

// go scratch.CreateGif(sim, time.Millisecond*100, time.Millisecond*100, "./examples/tumbler/tumbler.gif", 100)

// Run the processing loop forever.
for {
time.Sleep(time.Millisecond * 10)
Expand Down
Binary file added examples/tumbler/tumbler.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 42f707d

Please sign in to comment.