User Tools

Site Tools


notes:discrete:fall2023:projects:yol0

This is an old revision of the document!


yol0

let's gooooooo

edit/add pertinent sections as needed

Creating a Matrix

NOTE: The following matrix is based on the following texture file: https://github.com/vircon32/ConsoleSoftware/blob/main/Games/BasicPlatformer/textures/TextureTextFont.png

Notice how the letters in the file are laid out in a grid pattern. This indicates that using a matrix is the best option and will make it way easier to create our custom font.

Start off by defining our texture and regions in our texture file.

// Texture in Cartridge
#define TextureTextFont 0
// Region definition
#define FirstRegionTextFont 1

In your main loop you will want to select the texture and instead of using define_region use define_region_matrix.

Vircon gives the following description of define_region_matrix “Defines a set of same-sized regions within the selected texture that are laid out as a rectangular matrix. Consecutive IDs will be defined from left to right, and top to bottom. All regions will have the same relative hotspot position.”

Here is the format for define_region_matrix:

define_region_matrix(RegionID, TopleftX, TopleftY, BottomrightX, BottomrightY, HotspotX, HotspotY, rows, columns);

For the specific texture font in this case this is what it should look like in your main:

    // Selecting texture in cartridge
    select_texture( TextureTextFont );
 
    // Creating matrix for texture file
    define_region_matrix( FirstRegionTextFont,  0,0,  21,31,  0,31,  16,8,  0 );

scaling numbers

There are a few different functions in vircon32 that can help change the things you display to a better size. one of those being to scale the image on the x and y. This can be very helpful if the numbers or images you have are too big or small. To change the size of the image; you have to first set the drawing scale, you can think of this as the number you want to multiply the size of the image by. It takes two floats as inputs so you can change the size of the image to your preference. Then instead of using the draw_region_at(); function you would use the draw_region_zoomed_at(x,y); to draw your new bigger/smaller image on the screen.

  float scale = 3;
  set_drawing_scale(scale,scale);
  //select_texture();
  //select_region();
  draw_region_zoomed_at(x,y);

Custom Texture File

This is the png file that will contain the numbers you will be using to print to the screen. The numbers can be arranged depending on functionality you use to print the numbers to the screen, as well as how you would like to define the regions. One way to go about this is to have the numbers arranged in symmetrical tiles and define them using the “define_region_matrix” function. With this you can assign an int value to each tile/number and call that value to print your texture region to the screen.

notes/discrete/fall2023/projects/yol0.1697467892.txt.gz · Last modified: 2023/10/16 14:51 by wgates1