You said Ruby is only for web coding? Revealing. I use Ruby to make Music Video.

Tram Ho

The post is not very technical – mainly I want to express my ideas about code. Not that lately, I’ve been thinking quite seriously about all kinds of “what for?” Questions. .

Live to do ? Code to do? What to eat for? Sleep for what?

In my rambling thoughts, I accidentally remembered the question of my fellow Java code: “My brother Hieu, what can Ruby language do? You see your brother told me to just code the web?”

Hehe, you are wrong. If it’s for the money, then maybe it’s true that Ruby is just for Web coding. But I code for my soul, because love is burning in my administration. (The back of the neck is very scorched, someone loves it, so they set up to love code, clear literature)

I love programming. And also, I’m an amateur music maker (also for love).

So I decided to interrupt the current inference to use Ruby to code the Music Video for it to fear.

1. Make music and video ideas

Return to the question at the beginning of the post:

What is my life for ?

Personally, I live for love (love money) . Money, beauty, fame, contention, a desire to win, … all vanish with time. Love will be the last remaining thing.

With that message, I have produced a song called “Love last” at this link .

The problem now is that at the end of the month, I don’t have money to invest Music Video for it. So combined with the story of Java dev children that you all know, I decided to code out 1 Music Video to save money. Specifically, the idea is that I will use the gosu gem to code a game that matches the message of my song.

Gem gosu is a 2D game library, used to program games in Ruby and C ++ languages. Its community is also relatively large. You can read more documentation about it here

2. Install gosu gem and find game

To use gosu, you must first install the gem gosu . I will guide you to install on Ubuntu with the following 2 basic commands:

If you use another OS, please refer to the gem installation instructions here .

After installing the gem, and messing around on google a bit, I found a sourcecode containing a game that matches my music. That is the sourcecode of the gem gosu-examples . To use it, download the directory here .

The game I will use is game tutorial.rb . You can run it as follows:

And it will display as follows:

A pretty familiar game, isn’t it.  Now I will find a way to edit its image a bit to suit my music video.

3. Fix a bit of the game’s graphics

I will edit 3 things to suit the spirit of the video:

  • Firstly, I will replace the ship with my music channel logo .
  • Second, I will replace the image of the stars with the image of hearts – representing love.
  • Third, I will replace the dark cosmic background with an image on which my producer tag was recorded.

It seems that changing images in sourecode seems easy and done in the blink of an eye. But when I do, I have some small problems. Problem # 1, when replacing the ship with the music channel logo it looks like this:

What you are seeing is that my music logo image is too big, blocking all the game screen.

After reading in the sourecode in the paragraph below and doing a little calculation, I see that my logo needs to be 64x64 size to look good on the game screen.

I use MiniMagick (a Ruby image processing library) to create a 64x64 image file from my logo:

Then, I change the image file in the game’s sourcecode to the newly created cpnt.png file:

I also use the same MiniMagick for the case of changing the star image and background of the game, the result is a complete Music Video like this.

 

To summarize, in addition to making the web, Ruby can also do some more things such as: game code, image processing, basic data processing, creating some libraries for other languages, … ..

Or sometimes used to do bad graphics for an affordable Music Video like this.

In general, like the message of the song, if it is for love, we will find a way to use seemingly useless things for nothing.

Love always last.

Thank you for following this article.

Remember to choose your own music making channel if you are interested. cracked.

This article is clearly an advertisement and shares what mother technique.

Share the news now

Source : Viblo