faiface/pixel

No error but window doesnt show

Closed this issue · 4 comments

Hi, I'm trying to build a game, I'm completely new to this... and I don't know how to structure a code...
I've those tree codes
This one which juste defines window :

package auxiliaire 

import (
	"github.com/faiface/pixel"
	"github.com/faiface/pixel/pixelgl"
)

//Config des fenêtres
var Dimension pixel.Rect = pixel.R(0, 0, 1400, 780) //dimenseion

var MainWindowCfg = pixelgl.WindowConfig{
	Bounds:    Dimension,
	Resizable: true,
	VSync:     true,
	Title:     "IACATS",
}

var MainWindow, _ = pixelgl.NewWindow(MainWindowCfg)
var Centre pixel.Vec = MainWindow.Bounds().Center()

This one which (in the future) run a level :

package niveaux

import (
	"jeu/auxiliaire"

	_ "github.com/faiface/pixel"
	_ "github.com/faiface/pixel/pixelgl"
	"golang.org/x/image/colornames"
)

func LaunchLvTest() {
	WindowLvTest := auxiliaire.MainWindow
	backgroundColor := colornames.Cornflowerblue
	for !WindowLvTest.Closed() {
		WindowLvTest.Clear(backgroundColor)
		WindowLvTest.Update()
	}
}

and the last one which is main :

package main

import (
	"jeu/niveaux"

	_ "github.com/faiface/pixel"
	"github.com/faiface/pixel/pixelgl"
)

func run() {
	niveaux.LaunchLvTest()
}

func main() {
	pixelgl.Run(run)
}

but it doesn't show any window just printing this in the terminal

(base) MBPdeAlexandre:jeu frostways$ go run main.go 
niveaux/niveautest.go:4:2: found packages auxiliaire (animations.go) and main (fenetres.go) in /Users/frostways/go/src/jeu/auxiliaire

delp commented

I suspect this has something to do with the way you are setting up your packages. Can you show your golang env variables like $GOPATH, $GOROOT, $GO111MODULE and the paths that those files are in please?

I suspect this has something to do with the way you are setting up your packages. Can you show your golang env variables like $GOPATH, $GOROOT, $GO111MODULE and the paths that those files are in please?

It was just a misunderstanding of how go packages are working.
Ty fort you time <3

delp commented

Glad to hear you solved your problem, thanks for using Pixel

Glad to hear you solved your problem, thanks for using Pixel

Yeah I'm really enjoying this library but since I'm kinda new to programming and because there is not a lot of learning ressources about pixel (and I don't know the "regular" ways to code a game) It's quite hard but I enjoy the journey by now! Fortunately I'm studying math and physics at university... It helps for modelisation understanding and having ideas :')