Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this task you use Gosu to create a program that draws a picture. Gosu is a development environment that makes it easy to create

In this task you use Gosu to create a program that draws a picture.

Gosu is a development environment that makes it easy to create programs that use graphics, sounds, animations and other aspects relevant to creating small interactive games.

Please post the full code in its entirety as the final answer (Has to work!). Any change from this request or deviation from this will result in a report!

image text in transcribed

Provided Ruby Code: Curves_gosu.rb:

require 'rubygems'

require 'gosu'

require './bezier_curve'

# The screen has layers: Background, middle, top

module ZOrder

BACKGROUND, MIDDLE, TOP = *0..2

end

class DemoWindow

def initialize

super(400, 400, false)

self.caption = "Curves Example"

end

def needs_cursor?

true

end

def draw

draw_curve(150, 25, 150, 75, 100, 25, 200, 75, 2, Gosu::Color::YELLOW, 5)

draw_curve(100, 25, 100, 75, 50, 25, 150, 75, 2, Gosu::Color::YELLOW, 5)

draw_curve(200, 25, 200, 75, 150, 25, 250, 75, 2, Gosu::Color::YELLOW, 5)

draw_curve(100, 100, 100, 150, 75, 100, 75, 150, 2, Gosu::Color::BLUE, 10)

draw_curve(100, 100, 100, 150, 125, 100, 125, 150, 2, Gosu::Color::BLUE, 10)

draw_curve(200, 100, 200, 150, 175, 100, 175, 150, 2, Gosu::Color::BLUE, 10)

draw_curve(200, 100, 200, 150, 225, 100, 225, 150, 2, Gosu::Color::BLUE, 10)

draw_curve(100, 200, 200, 200, 125, 250, 175, 250, 2, Gosu::Color::RED, 10)

end

end

DemoWindow.new.show

In this task you use Gosu to create a program that draws a picture. Gosu is a development environment that makes it easy to create programs that use graphics, sounds, animations and other aspects relevant to creating small interactive games. Follow these 4 steps: Step 1: Copy the code provided to your IDE (both gosu_shapes.rb and circle.rb) and use the demonstration shapes to create a picture of your own design. Your picture should include at least 3 different types of shapes (eg: a triangle, a rectangle and a circle). For example, a Red circle with a radius of 50 pixels would be produced by the two statements: img=Gosu::Image.new(Circle.new(50))img.draw(200,200,Zorder::TOP,0.5,1.0,Gosu::Color::RED) Or you could use the HEX values: \[ \text { img.draw }(300,50, \text { Zorder::TOP, 1.0, 1.0, 0xff_ff0000) } \] Resources for this step: - Use RGB Color Codes Chart (Rapid tables 2021) to select colours for the circle (which uses RGB values): - Or Use the Gosu colour constants in Class: Gosu::Color: (rubydoc 2021). - Use Decimal to Hexadecimal Converter to work out the HEX values (www.Binary WexConverter.com 2021). Step 2: Run the code provided and study it to understand what is happening (you may need to run the command gem install rubygems to use the circle.rb code). Step 3: Using an IDE like Visual Studio Code, change the code to draw your own unique picture. You might want to draw it on paper first. See 3.6 Graphical programming (shape drawing) in Canvas for more tips. Step 4: Once your code is complete, upload a screenshot to your workspace. Upload a screenshot to your workspace below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions