MCPcopy Create free account
hub / github.com/SolarLune/masterplan / GridCursorPosition

Method GridCursorPosition

contents.go:3149–3177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3147}
3148
3149func (mc *MapContents) GridCursorPosition() Vector {
3150
3151 mp := globals.Mouse.WorldPosition()
3152 mp = globals.Project.Camera.UntranslatePoint(mp)
3153
3154 mp = mp.Sub(globals.Project.Camera.TranslatePoint(Vector{mc.Card.Rect.X, mc.Card.Rect.Y}))
3155
3156 // cardPos := Point{mc.Card.Rect.X, mc.Card.Rect.Y}
3157
3158 mp.X = float32(math.Floor(float64((mp.X) / globals.GridSize)))
3159 mp.Y = float32(math.Floor(float64((mp.Y) / globals.GridSize)))
3160
3161 if mp.X < 0 {
3162 mp.X = 0
3163 }
3164 if mp.Y < 0 {
3165 mp.Y = 0
3166 }
3167
3168 if mp.X > (mc.RenderTexture.Size.X/globals.GridSize)-1 {
3169 mp.X = (mc.RenderTexture.Size.X / globals.GridSize) - 1
3170 }
3171 if mp.Y > (mc.RenderTexture.Size.Y/globals.GridSize)-1 {
3172 mp.Y = (mc.RenderTexture.Size.Y / globals.GridSize) - 1
3173 }
3174
3175 return mp
3176
3177}
3178
3179func (mc *MapContents) RecreateTexture() {
3180

Callers 2

UpdateMethod · 0.95
DrawMethod · 0.95

Calls 4

WorldPositionMethod · 0.80
UntranslatePointMethod · 0.80
TranslatePointMethod · 0.80
SubMethod · 0.45

Tested by

no test coverage detected