How to Make Gosu Ruby Basic Shapes












0















I am trying to make some simple shapes in gosu (ruby). I am finding it difficult where to call the functions. Is it update method or the draw method.



   require 'rubygems'
require 'gosu'

class DemoWindow < Gosu::Window
def initialize
super(640, 400, false)
end

def draw
draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

end
end


Please take a look and let me know if this is the right way to create shapes.










share|improve this question























  • yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

    – David Unric
    Feb 24 '13 at 16:45
















0















I am trying to make some simple shapes in gosu (ruby). I am finding it difficult where to call the functions. Is it update method or the draw method.



   require 'rubygems'
require 'gosu'

class DemoWindow < Gosu::Window
def initialize
super(640, 400, false)
end

def draw
draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

end
end


Please take a look and let me know if this is the right way to create shapes.










share|improve this question























  • yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

    – David Unric
    Feb 24 '13 at 16:45














0












0








0








I am trying to make some simple shapes in gosu (ruby). I am finding it difficult where to call the functions. Is it update method or the draw method.



   require 'rubygems'
require 'gosu'

class DemoWindow < Gosu::Window
def initialize
super(640, 400, false)
end

def draw
draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

end
end


Please take a look and let me know if this is the right way to create shapes.










share|improve this question














I am trying to make some simple shapes in gosu (ruby). I am finding it difficult where to call the functions. Is it update method or the draw method.



   require 'rubygems'
require 'gosu'

class DemoWindow < Gosu::Window
def initialize
super(640, 400, false)
end

def draw
draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

end
end


Please take a look and let me know if this is the right way to create shapes.







ruby libgosu






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 24 '13 at 13:12









Ryu IshidaRyu Ishida

2017




2017













  • yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

    – David Unric
    Feb 24 '13 at 16:45



















  • yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

    – David Unric
    Feb 24 '13 at 16:45

















yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

– David Unric
Feb 24 '13 at 16:45





yes, you can draw primitives in gosu this way, in the draw method. i would suggest to set all attributes like colors, images etc. in the initialize method. do you have some concrete issues ?

– David Unric
Feb 24 '13 at 16:45












2 Answers
2






active

oldest

votes


















0














From what I'm seeing what you've got should work.



One thing I've noticed about Gosu is that when it first starts up it calls the draw method before it calls the update function. What that means is if you have (not including the shape functions you're using) any images you are going to draw to the screen that you only have defined coordinates for in the update method the program won't work. You've got to define their x and y values with some preliminary location in the draw method first.



This probably won't help you but I thought I'd contribute it on the off chance it might.






share|improve this answer































    0














    From what I have noticed that you do not have update method therefore it is not rendering



     class DemoWindow < Gosu::Window
    def initialize
    super(640, 400, false)
    end

    def update
    end

    def draw
    draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
    draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
    draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

    end





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15052056%2fhow-to-make-gosu-ruby-basic-shapes%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      From what I'm seeing what you've got should work.



      One thing I've noticed about Gosu is that when it first starts up it calls the draw method before it calls the update function. What that means is if you have (not including the shape functions you're using) any images you are going to draw to the screen that you only have defined coordinates for in the update method the program won't work. You've got to define their x and y values with some preliminary location in the draw method first.



      This probably won't help you but I thought I'd contribute it on the off chance it might.






      share|improve this answer




























        0














        From what I'm seeing what you've got should work.



        One thing I've noticed about Gosu is that when it first starts up it calls the draw method before it calls the update function. What that means is if you have (not including the shape functions you're using) any images you are going to draw to the screen that you only have defined coordinates for in the update method the program won't work. You've got to define their x and y values with some preliminary location in the draw method first.



        This probably won't help you but I thought I'd contribute it on the off chance it might.






        share|improve this answer


























          0












          0








          0







          From what I'm seeing what you've got should work.



          One thing I've noticed about Gosu is that when it first starts up it calls the draw method before it calls the update function. What that means is if you have (not including the shape functions you're using) any images you are going to draw to the screen that you only have defined coordinates for in the update method the program won't work. You've got to define their x and y values with some preliminary location in the draw method first.



          This probably won't help you but I thought I'd contribute it on the off chance it might.






          share|improve this answer













          From what I'm seeing what you've got should work.



          One thing I've noticed about Gosu is that when it first starts up it calls the draw method before it calls the update function. What that means is if you have (not including the shape functions you're using) any images you are going to draw to the screen that you only have defined coordinates for in the update method the program won't work. You've got to define their x and y values with some preliminary location in the draw method first.



          This probably won't help you but I thought I'd contribute it on the off chance it might.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 17 '13 at 4:31









          cyclingLinguistcyclingLinguist

          114212




          114212

























              0














              From what I have noticed that you do not have update method therefore it is not rendering



               class DemoWindow < Gosu::Window
              def initialize
              super(640, 400, false)
              end

              def update
              end

              def draw
              draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
              draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
              draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

              end





              share|improve this answer






























                0














                From what I have noticed that you do not have update method therefore it is not rendering



                 class DemoWindow < Gosu::Window
                def initialize
                super(640, 400, false)
                end

                def update
                end

                def draw
                draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
                draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
                draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

                end





                share|improve this answer




























                  0












                  0








                  0







                  From what I have noticed that you do not have update method therefore it is not rendering



                   class DemoWindow < Gosu::Window
                  def initialize
                  super(640, 400, false)
                  end

                  def update
                  end

                  def draw
                  draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
                  draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
                  draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

                  end





                  share|improve this answer















                  From what I have noticed that you do not have update method therefore it is not rendering



                   class DemoWindow < Gosu::Window
                  def initialize
                  super(640, 400, false)
                  end

                  def update
                  end

                  def draw
                  draw_quad(x-size, y-size, 0xffffffff, x+size, y-size, 0xffffffff, x-size, y+size, 0xffffffff, x+size, y+size, 0xffffffff, 0)
                  draw_triangle(x1, y1, c1, x2, y2, c2, x3, y3, c3, z=0, mode=:default)
                  draw_line(x1, y1, c1, x2, y2, c2, z=0, mode=:default)

                  end






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 1 at 1:15

























                  answered Jan 1 at 1:08









                  Merey NurlanMerey Nurlan

                  12




                  12






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15052056%2fhow-to-make-gosu-ruby-basic-shapes%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Monofisismo

                      Angular Downloading a file using contenturl with Basic Authentication

                      Olmecas