-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vmars improvements and fixes #58
base: master
Are you sure you want to change the base?
Conversation
9afddeb
to
5665316
Compare
g.sim.Reset() | ||
g.sim.SpawnWarrior(0, 0) | ||
g.sim.SpawnWarrior(1, gmars.Address(rand.Intn(7000)+200)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bug - hardcoded position causes crashes on restarts.
warriorColors[1].Scale(1, 1, 0, 1) | ||
warriorColors[2].Scale(0, 1, 1, 1) | ||
const ( | ||
SpriteFirst = iota |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used these markers so that it's easy to add sprites at the beginning and end, without redoing the code.
g.spriteCache[sprnum] = make([]*ebiten.Image, len(g.hues)) | ||
for i, hue := range g.hues { | ||
var c colorm.ColorM | ||
c.ChangeHSV(hue/180.0*math.Pi, 1.0, 1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out any other way to vary hue. The color scale thing is RGB, so not that useful.
|
||
// cacheColors precomputes colors to use for static display, such as text. This | ||
// color matches dominant color of the sprite tileset. | ||
func (g *Game) cacheColors() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this isn't really required for performance, more for developer ergonomics, so that it's easy to pick solid colors for e.g. text.
5665316
to
b8a1956
Compare
This is useful for restarts.
Ebiten can handle scaling and aspect ratio natively.
b8a1956
to
e2b0f8b
Compare
Review notes
Probably easiest to go commit by commit, I've split things up and added some context.
Demo
demo.webm