-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started: Your First ConsoleGL App
Now you have ConsoleGL installed. It's time to make your first ConsoleGL App. Lets Start by importing ConsoleGL
require 'ConsoleGL'Good Job! Now Lets Start coding..
For your first app we are going to be making a very simple loop that draws 1 green box and 4 red boxes. Sounds simple but its a great way to learn about ConsoleGL
Lets Start by making a simple counter
require 'ConsoleGL'
counter = 0
while true do
counter += 1
endGreat! This part is not a part of ConsoleGL but it will be really useful for this app.
Now Lets Add Some Colors!
require 'ConsoleGL'
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
counter += 1
endThis Won't do anything yet. But that's because we need to call the Console.Draw() Function
Lets get some graphics into our app
Lets Start with calling the Console.Draw() Function
require 'ConsoleGL'
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
Console.Draw()
counter += 1
endIf we run this now we will get an error.
This is because we need to specify what to draw to the Console
require 'ConsoleGL'
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
Console.Draw(Console.BigSquareMiddle())
counter += 1
endGreat! Now we are drawing a Big Square to the console. But we need to add color to it or else it won't work.
require 'ConsoleGL'
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
Console.Draw(Console.BigSquareMiddle(currentColor))
counter += 1
endAmazing! But we aren't done yet. Lets add some finishing touches
We need to reset the color and create a new line every 4 times the loop gets executed
require 'ConsoleGL'
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
Console.Draw(Console.BigSquareMiddle(currentColor))
if counter > 4
counter = 0
Console.NewLine
else
counter += 1
end
endWe also need to set the title
require 'ConsoleGL'
Console.SetTitle("My First ConsoleGL App")
counter = 0
while true do
if counter == 0
currentColor = Color.WHITE
elsif counter == 1
currentColor = Color.GREEN
else
currentColor = Color.RED
end
Console.Draw(Console.BigSquareMiddle(currentColor))
if counter > 4
counter = 0
Console.NewLine
else
counter += 1
end
endNow Try Running it!
