Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / NameError
- - By Idiot Date 2017-12-15 06:16
I got the background image working when I got to the player part of the tutorial I got this error

I can't figure out why
Attachment: error.PNG (3k)
Parent - - By jlnr (dev) Date 2017-12-15 10:27
What does your code look like? Can you please attach your .rb file?
Parent - - By Idiot Date 2017-12-15 11:12
Yeah, thanks!
Attachment: game.rb (850B)
Attachment: player.rb (600B)
Parent - - By jlnr (dev) Date 2017-12-17 02:46
game.rb needs a require_relative 'player' at the top :)
Parent - - By Idiot Date 2017-12-17 05:51
I should have realized that, sorry.
But now I get a different error?

I went to the player file and did require gosu to see if that would change anything, it didn't.
How come I can't figure this out?
Attachment: game.rb (880B)
Attachment: player.rb (616B)
Attachment: gosuplease.PNG (10k)
Parent - - By jlnr (dev) Date 2017-12-17 15:19 Edited 2017-12-22 11:17
Do you have a folder assets next to the Ruby source code files, and does it contain an image named starfighter.png? How do you run your game?
Parent - - By Idiot Date 2017-12-17 18:50
Yes, my assets folder is next to the game and player ruby files.
I'm running my game through cmd

> cd desktop
> cd folder
>cd ruby game.rb


I ran an open sourced gosu game from github a few days ago and it worked fine?
Parent - - By jlnr (dev) Date 2017-12-22 11:17
You mean ruby game.rb, right? No idea. What does this print if you run this as the first line in your Ruby script:

p File.exist? "assets/starfighter.png"
Parent - - By Idiot Date 2017-12-22 22:31
I got the same error.

I decided to look in the compact.rb file where there's supposed to be an error at line 84 but I can't tell if there's something wrong.

What does yours look like?
Attachment: compat.rb (6k)
Attachment: ahaheuahe.PNG (16k)
Parent - By jlnr (dev) Date 2017-12-31 13:55
This little debug statement doesn't try to fix the issue, but it should print true or false in the terminal when you run the game, depending on whether the file can be found.
Parent - By jlnr (dev) Date 2017-12-31 13:56
The compat.rb file overrides a few methods in Gosu, so the stack trace will usually include this file even if the error happens in a completely different file. Interpreting these errors is tough, but gets easier with time.
- - By Idiot Date 2017-12-30 17:36
So I found out what the problem was, that player class needed to be stated before my game class.
Sorry.
Parent - By jlnr (dev) Date 2017-12-31 13:53
Sorry for not replying earlier, but glad you found it :)
Up Topic Gosu / Gosu Exchange / NameError

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill