Dicee GAME – Fyne GUI Golang tutorial 17

Want to Create your first Game in Fyne and Golang?

I think Now we have enough skills and knowledge to create a small game in Fyne & Golang.

 

Lets do it.

 

[sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”] package main

// import fyne
import (
"fmt"
"math/rand"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)

func main() {
// New app
a := app.New()
// New window and Title
w := a.NewWindow("Dicee Game")
// resize Window
w.Resize(fyne.NewSize(400, 400))
// image of Dice
img := canvas.NewImageFromFile("c:/dice/dice6.jpg")
img.FillMode = canvas.ImageFillOriginal
// button
btn1 := widget.NewButton("Play", func() {
// UI is finished.. Now Logic part
rand := rand.Intn(6) + 1 // ignore zero 0+1=1
img.File = fmt.Sprintf("c:/dice/dice%d.jpg", rand)
img.Refresh()
})
// Setup content and finish UI
w.SetContent(
// NewVBox.. More than on Widgets
container.NewVBox(
img,
btn1,
),
)
// show and run app
w.ShowAndRun()
}

[/sourcecode]

Fyne GoLang GUI Course

 

[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main17.go” text=”Download Code” color=”red_darker”]
Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 9 comments
Vineet - 3 years ago

Bro where do i find the dice images.

Reply
    Tony BB - 3 years ago

    Already sent you email 🙂

    Reply
Vineet - 3 years ago

Bro where do i find the dice images…

Reply
Ramu - 3 years ago

bro Kindly send the dicee imgage please.

Reply
    Tony BB - 3 years ago

    Check your email 🙂

    Reply
sauskeu - a couple of years ago

Bro please send me the dicee image.

Reply
Raihan - a couple of years ago

Please give me image link

Reply
walter - a couple of years ago

images link folder plz ser

Reply
    Tony BB - a couple of years ago

    Sent

    Reply

Leave a Reply: