Skip to main content
GameDev.net gamedev.net
🔒 Locked

Font Scroll, how?

Started by cebugdev Jul 12, 2006 at 2:10 AM 2 replies 650+ views
Original Post
cebugdev
cebugdev
hi do u guys have any idea on how to scroll font? by scrolling i mean given a rectangular window the the font reaches the right end of the window it then continue to display back at the left. ( like that of snake game ) How do i Do this? im planning to implement it in MFC or in any other platform if only i just have an idea on how. thanks
Evil Steve
Evil Steve
It depends how you draw text normally. If you're using GDI, you just change the X-offset you draw the text at. You'd also want to get the length of the string in pixels, and if it'll overflow, you draw the text again on the left, using a negative offset so you only see the end of the string.

We'll need more details (Language, API, etc) if you want some code example.
cebugdev
cebugdev
hi im planning to use MFC and draw it in GDI, yeah ive already got the idea of changing the offset but how to implement the text when it reaches an edge it will continue on the other edge?
Evil Steve
Evil Steve
Quote:
Original post by Evil Steve
You'd also want to get the length of the string in pixels, and if it'll overflow, you draw the text again on the left, using a negative offset so you only see the end of the string.
You can get the length of a string in GDI using GetTextExtentPoint32, and then you'd see how much it overflows your window by, and draw the text again on the left using an offset of overflow_amount - text_length.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.