Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


SDL Keypress to ASCII PROBLEM!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Pepsi   Members   -  Reputation: 95

Like
-2Likes
Like

Posted 19 September 2012 - 01:22 PM

REMOVE THIS TOPIC.
I SOLVED THE PROBLEM.

Edited by Pepsi, 19 September 2012 - 07:33 PM.


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 6254

Like
0Likes
Like

Posted 19 September 2012 - 01:27 PM

Use key.unicode instead of key.sym? Not sure if it already handles things such as shift and etc, but it's a start...

EDIT:
Misread the post.

Generally, you'd have a table of SDL_Rects you index into to select where in the bitmap that character resides:

Slightly pseudo-code:
SDL_Rect glyphBounds[256];

// load into file
std::ifstream fs( "bitmap_font.txt" );
for ( int idx = 0; idx < 256 && fs >> glyphBounds[idx]; ++idx )
    ;

// draw:
std::string str = "Hello";
int x = 0, y = 0;
for ( int idx = 0; idx < str.length(); ++idx ) {
     const SDL_Rect& r = glyphBounds[str[idx]];
     draw( x, y, bmpFont, r );
     x += r.width;
}

Edited by fastcall22, 19 September 2012 - 01:34 PM.

gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=

#3 Pepsi   Members   -  Reputation: 95

Like
0Likes
Like

Posted 19 September 2012 - 01:30 PM

Thanks for your help Posted Image.

Edited by Pepsi, 19 September 2012 - 07:34 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS