Problems with PUT command, and a shifting Y coordinate

New to FreeBASIC? Post your questions here.
dcruze
Posts: 2
Joined: Jan 03, 2013 19:34

Problems with PUT command, and a shifting Y coordinate

Postby dcruze » Jan 03, 2013 19:51

Hi, I've just started coding with FreeBasic.

I have a couple of problems with my first program:

1) the Y coordinate seems to shift halfway through the program, and I can't figure out why.

2) I'm using the GET command to get a piece of a bitmap font which is white on a purple background. I used photoshop to make the purple the alpha channel. What I need is a way to be able to change the color of the font from white to any color I want. I think CUSTOM might do it, but I'm stumped.

Here's my mess of a program:

Code: Select all

 #include once "fbgfx.bi"

ScreenRes 1024, 768, 32, 2    'Sets up the screen to be 1024x768 in 32-bit color with 3 video pages.

Line (0,0)-(1023,200),RGB(255, 0,0), bf   ' draws a red box in its correct place
sleep

ScreenSet 1,0   ' working page 1, displayed page 0
BLoad"untitled.bmp"
Dim As fb.Image Ptr tile = ImageCreate(32,32)
Get (32,32)-(63,63), tile     ' here i get a character from my bitmap font, still in its correct place, coordinates-wise

ScreenSet 0,0
cls
Line (0,8)-(1023,200),RGB(255, 0,0) , bf
Put (2,32),tile, xor

   ' now the Y coordinate for some reason has shifted 8 pixels up

Locate 96,116
Print"Hello World!"
Sleep


Thanks for any help :)
Destructosoft
Posts: 88
Joined: Apr 03, 2011 3:44
Location: Inside the bomb
Contact:

Re: Problems with PUT command, and a shifting Y coordinate

Postby Destructosoft » Jan 03, 2013 23:33

Is the problem that your two LINE commands aren't identical? The first one starts at 0,0 and the second one at 0,8, which is 8 pixels lower, making the put tile look higher.

Also, you're using 2,32 in the second tile instead of 32,32.

As for recoloring a custom font, I had that problem about 4 years ago. You'll need to make full use of alpha transparency, or go with B&W for the custom font (using black as background), and then Draw String with And onto a color rectangle.

Anyway, experimentation is the key.
dcruze
Posts: 2
Joined: Jan 03, 2013 19:34

Re: Problems with PUT command, and a shifting Y coordinate

Postby dcruze » Jan 04, 2013 6:18

Thanks, I'll try the draw string thing.

The coordinate shift was just caused by using PRINT at the very bottom of the screen. It of course shifted things 8 pixels up (linebreak). *facepalm*

Thanks for replying.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 1 guest