Fifth week – Arkanoid and SDL

During last weeks lectures our lecturer started live coding for Arkanoid (or Breakout). We went through some of the basic stuff you need for almost any game, the engine and a couple of managers. This week we finished it by adding stuff specific to Arkanoid (blocks, paddle, ball and movement; in short, the logic of the game). We also implemented SDL_Image and SDL_TTF as an addition.

In SDL you can only handle .bmp images, and to be able to utilize for example transparency in images we must use a different kind of image (.PNG for example). This could be done with the SDL_Image library. It could take almost any kind of image, but there is one problem. When loading in a image to a surface we don’t know what kind of image it is. Thus we have to convert it to a format that we desire by using SDL_ConvertSurfaceFormat(parameters) and then making it into a texture which we could use in our game.

In a similar way we could insert text into the game, though as images, with the SDL_TTF library. With TTF_OpenFont(parameters) we load in a desired font and then create a new instance of an inherited class SpriteText from our Sprite class. This SpriteText class takes the font and the text and creates a surface with TTF_RenderText_Solid(parameters), much like we did with images. We also convert this surface into a desired format with SDL_ConvertSurfaceFormat(parameters) and then create a texture which can be used in our game.

From now on we are going to mainly focus on our own projects and I have started looking up different kinds of Bomberman games for inspiration.

Best Regards,

Sven

Music of the week: Hungarian Dance no. 5 – Brahms

About Sven Almberg

2014  Programming