Skip to content

Commit

Permalink
Finalize ep 1
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Aug 8, 2018
1 parent cdf528f commit 957b525
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,3 +12,4 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
/.idea
/saved
10 changes: 8 additions & 2 deletions README.md
@@ -1,2 +1,8 @@
# gad
Go After Dark
# Go After Dark

# Installing

# Running

# Web Assembly

3 changes: 2 additions & 1 deletion dentro/index.html
Expand Up @@ -24,6 +24,7 @@
<source src="./music/music.mp3" type="audio/mpeg">
<source src="./music/music.ogg" type="audio/ogg">
</audio>

<h1>-> <a href="https://youtu.be/yeWWqF8MrkY">Watch Go After Dark Episode 1</a></h1>
<p>If your browser doesn't support Web Assembly, you can <a href="https://youtu.be/0rQVJIbk-pE">watch a youtube version of this</a>.</p>
</body>
</html>
45 changes: 39 additions & 6 deletions dentro/main.go
Expand Up @@ -27,8 +27,8 @@ const (

func main() {
fx := newFx("data/scene.obj", "data/flower.png", "data/light.png")
gfx.Run(func() { gfx.RunTimedMusic(fx, "music/music.mp3") })
//gfx.RunWriteToDisk(fx, 1, "./saved/frame-%05d.png")
//gfx.Run(func() { gfx.RunTimedMusic(fx, "music/music.mp3") })
gfx.RunWriteToDisk(fx, 11, "./saved/frame-%05d.png")
}

type coord struct{ x, y, z float32 }
Expand All @@ -41,7 +41,7 @@ func (c *coord) scale(f float32) {

var texts = [][2]string{
{
`--- >> Prepare for Go After Dark << ---`,
`--- >> Welcome to Go After Dark << ---`,
`.oOoOoOoOoOo. .oO0Oo. .oO0OoO0OouoO0Oo.`,
},
{
Expand All @@ -57,8 +57,12 @@ var texts = [][2]string{
`and code awesome looking effects. `,
},
{
`Check out the links below and follow + `,
`subscribe on Twitter and Youtube. `,
`Check out the links below to watch `,
`the first episode. `,
},
{
`I have material ready for at least 10 `,
`episodes, if there is interest for this.`,
},
{
`>> Credits << `,
Expand All @@ -74,7 +78,11 @@ var texts = [][2]string{
},
{
`Pure software rendering in Go, compiled `,
`to Web Assembly by Go 1.11 Beta. `,
`to Web Assembly by Go 1.11 (beta). `,
},
{
`There is links to all source code to `,
`build and run this demo. `,
},
}

Expand Down Expand Up @@ -461,3 +469,28 @@ func (f fp8x24) String() string {
func (f fp16x16) String() string {
return fmt.Sprintf("(%d,0x%x)", uint32(f)>>16, uint16(f))
}

func init() {
var palette [256]uint32
rC, gC, bC := 180, 180, 255
flip := 192
flipScale := int(256.0 * (256.0 / float64(flip)))
flipScale2 := int(256.0 * (256.0 / float64(255-flip)))
for i := range palette[:] {
var r, g, b int
if i < flip {
r = (i*rC*flipScale + 128) >> 16
g = (i*gC*flipScale + 128) >> 16
b = (i*bC*flipScale + 128) >> 16
} else {
r = rC
g = gC
b = bC
r += ((i - flip) * (255 - rC) * flipScale2) >> 16
g += ((i - flip) * (255 - gC) * flipScale2) >> 16
b += ((i - flip) * (255 - bC) * flipScale2) >> 16
}
palette[i] = uint32(r) | (uint32(g) << 8) | (uint32(b) << 16)
}
gfx.InitGreyPalette(palette)
}
33 changes: 33 additions & 0 deletions index.html
@@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Episode 1</title>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Episode list</h1>
<table>
<tr>
<td>Teaser</td>
<td>Welcome to Go After Dark</td>
<td><a href="dentro/">See teaser in browser</a></td>
<td><a href="https://youtu.be/0rQVJIbk-pE">Watch teaser on Youtube</a></td>
</tr>
<tr>
<td>Episode 1</td>
<td>Introduction and a basic effect</td>
<td><a href="ep01/">See effect in browser</a></td>
<td><a href="https://youtu.be/yeWWqF8MrkY">Watch Episode on Youtube</a></td>
</tr>
</table>
<h1>Resources</h1>
<ul>
<li><a href="https://github.com/klauspost/gad">Go After Dark Code</a>.</li>
<li><a href="https://youtube.com/sh0dan2">My Youtube Channel</a>.</li>
<li><a href="https://twitter.com/sh0dan">My Twitter</a>.</li>
</ul>

</body>
</html>
38 changes: 38 additions & 0 deletions style.css
Expand Up @@ -28,6 +28,7 @@
}

body {
color: whitesmoke;
width: 1280px;
margin: auto;
background: #111;
Expand All @@ -49,3 +50,40 @@ canvas {
align-self: center;
width: 1280px;
}

a:link {
color: white;
}

/* visited link */
a:visited {
color: white;
}

/* mouse over link */
a:hover {
color: orange;
}

/* selected link */
a:active {
color: grey;
}

table {
border-width: 1px;
border-style: dotted;
border-collapse: collapse;
border-color: #333;
width: 80%;
padding: 15px;
}

td {
text-align: left;
padding: 15px;
}

h1 {
color: orange;
}

0 comments on commit 957b525

Please sign in to comment.