Merge branch 'gen2brain:master' into master

This commit is contained in:
unkl nik 2023-10-21 22:23:52 +02:00 committed by GitHub
commit 32413f57ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 12 deletions

View file

@ -160,15 +160,15 @@ func (g *Game) Update() {
if !g.Fruit.Active {
g.Fruit.Active = true
g.Fruit.Position = rl.NewVector2(
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize+int32(g.Offset.X)/2),
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize+int32(g.Offset.Y)/2),
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize)+(g.Offset.X)/2,
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize)+(g.Offset.Y)/2,
)
for i := 0; i < g.CounterTail; i++ {
for (g.Fruit.Position.X == g.Snake[i].Position.X) && (g.Fruit.Position.Y == g.Snake[i].Position.Y) {
g.Fruit.Position = rl.NewVector2(
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize),
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize),
float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize)+g.Offset.X/2,
float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize)+g.Offset.Y/2,
)
i = 0
}

View file

@ -854,15 +854,51 @@ type MaterialMap struct {
// Model is struct of model, meshes, materials and animation data
type Model struct {
// Local transform matrix
Transform Matrix
MeshCount int32
Transform Matrix
// Number of meshes
MeshCount int32
// Number of materials
MaterialCount int32
Meshes *Mesh
Materials *Material
MeshMaterial *int32
BoneCount int32
Bones *BoneInfo
BindPose *Transform
// Meshes array (c array)
//
// Use Model.GetMeshes instead (go slice)
Meshes *Mesh
// Materials array (c array)
//
// Use Model.GetMaterials instead (go slice)
Materials *Material
// Mesh material number
MeshMaterial *int32
// Number of bones
BoneCount int32
// Bones information (skeleton) (c array)
//
// Use Model.GetBones instead (go slice)
Bones *BoneInfo
// Bones base transformation (pose) (c array)
//
// Use Model.GetBindPose instead (go slice)
BindPose *Transform
}
// GetMeshes returns the meshes of a model as go slice
func (m Model) GetMeshes() []Mesh {
return unsafe.Slice(m.Meshes, m.MeshCount)
}
// GetMaterials returns the materials of a model as go slice
func (m Model) GetMaterials() []Material {
return unsafe.Slice(m.Materials, m.MaterialCount)
}
// GetBones returns the bones information (skeleton) of a model as go slice
func (m Model) GetBones() []BoneInfo {
return unsafe.Slice(m.Bones, m.BoneCount)
}
// GetBindPose returns the bones base transformation of a model as go slice
func (m Model) GetBindPose() []Transform {
return unsafe.Slice(m.BindPose, m.BoneCount)
}
// newModelFromPointer - Returns new Model from pointer

View file

@ -166,6 +166,11 @@ func LoadImageColors(img *Image) []color.RGBA {
return (*[1 << 24]color.RGBA)(unsafe.Pointer(ret))[0 : img.Width*img.Height]
}
// UnloadImageColors - Unload color data loaded with LoadImageColors()
func UnloadImageColors(cols []color.RGBA) {
C.UnloadImageColors((*C.Color)(unsafe.Pointer(&cols[0])))
}
// LoadImageFromTexture - Get pixel data from GPU texture and return an Image
func LoadImageFromTexture(texture Texture2D) *Image {
ctexture := texture.cptr()