# Gosu "Name error" problem

**URL:** <https://www.ruby-forum.com/t/gosu-name-error-problem/162710>\
**Category:** Ruby\
**Created:** [March 13, 2009, 12:16am UTC](https://www.ruby-forum.com/t/gosu-name-error-problem/162710 "2009-03-13T00:16:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanesoban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@kanesoban](https://www.ruby-forum.com/u/kanesoban)\
**Post date:** [March 13, 2009, 12:16am UTC](https://www.ruby-forum.com/t/gosu-name-error-problem/162710/1 "2009-03-13T00:16:05Z")

</div>

Hello

I’m trying to write a program, that hopefully will turn into a simple  
strategy game sometime. For now, i’ve got to the point, where a new game  
window shows up.

Now i wrote a method that should draw a rectangle when you hold down the  
left mouse button, and move the mouse (like in any rts game, so that you  
can select multiple units). Now, this method obviously does not work,  
and i’m not sure why.  
If somebody could look at my code (its 1 page), and tell me the problem,  
i would be grateful. However, i’m using the ‘gosu’ module, so it is  
needed to run this program. I attached the code to this message.

---

<div class="post-metadata">

**Author:** ![kanesoban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@kanesoban](https://www.ruby-forum.com/u/kanesoban)\
**Post date:** [March 13, 2009, 2:21am UTC](https://www.ruby-forum.com/t/gosu-name-error-problem/162710/2 "2009-03-13T02:21:24Z")

</div>

Hello Zsolnai,

It looks like you mixed up Gosu’s interfaces for C++ and Ruby 🙂 In  
Ruby, it is simply draw\_quad (vs. graphics().drawQuad), or  
Window#draw\_quad to be more precise.  
Also, the last argument should be :default instead of Gosu::amDefault.  
You can leave it out, though.

The complete Ruby interface can be found at:  
[http://code.google.com/p/gosu/wiki/RubyReference](http://code.google.com/p/gosu/wiki/RubyReference)

More information and a forum dedicated to only Gosu can be found on  
[http://www.libgosu.org/](http://www.libgosu.org/).

Regards,  
Julian

---

<div class="post-metadata">

**Author:** ![kanesoban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@kanesoban](https://www.ruby-forum.com/u/kanesoban)\
**Post date:** [March 15, 2009, 2:01pm UTC](https://www.ruby-forum.com/t/gosu-name-error-problem/162710/3 "2009-03-15T14:01:22Z")

</div>

Thank you. Replacing Gosu::Graphics:drawQuad with just draw\_quad solved  
the problem. What i don’t understand, is why draw\_quad works, and  
Gosu::Graphics::draw\_quad doesn’t ?

---

<div class="post-metadata">

**Author:** ![kanesoban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@kanesoban](https://www.ruby-forum.com/u/kanesoban)\
**Post date:** [March 16, 2009, 5:36pm UTC](https://www.ruby-forum.com/t/gosu-name-error-problem/162710/4 "2009-03-16T17:36:27Z")

</div>

> What i don’t understand, is why draw\_quad works, andGosu::Graphics::draw\_quad doesn’t ?

Basically, because there is no Graphics class at all in the Ruby  
version of Gosu, where all the methods from Graphics have been moved  
to the Window class. Also, draw\_quad is a _method_;  
Gosu::Graphics::draw\_quad() would be a call to a _class method_ of  
Gosu::Graphics. So there’s only Gosu::Window#draw\_quad, and you’d call  
it on an instance of Window, or without any instance at all in the  
methods of your Window.

Regards,  
Julian
