|
How can I do this its driving me mad >.< (putpixel) |
Tomoso
Member #3,128
January 2003
|
I have a "radar" kinda thing in my game which draws pixels supposidly inside the radar (or white rectangle). Thing is my brains gone totally dead and how ever hard I think the answer just wont come. I'm kinda stuck in a loop or certain think pattern or w.e its called, and I know it dont work but i cant break it http://www.allegro.cc/files/attachment/589876 Heres the code Im using to draw it:
So how do I make it only draw inside the radar area? Lazy Noob - Blog |
BAF
Member #2,981
December 2002
|
To get those thumbnail thingies, use the img tag. You can read more about it by clicking the HTML Mockup Code link when you post. Also, if you use MS Paint you can save in png (which is better for screenshots than jpeg) or jpeg without using the trial version of a program. That aside, I don't see what your problem is... |
Tomoso
Member #3,128
January 2003
|
OK thanks, and Win98 Paint says only Bmp Lazy Noob - Blog |
BAF
Member #2,981
December 2002
|
Ah I forgot the only added that support in XP (or was it 2k?). As far as your problem, you could add a check that only draws the dots that are inside the radar... something like if(x > left side && x < right side && y > top && y < bottom) draw else ignore. |
CIRCLE
Member #5,301
December 2004
|
what I am getting is this crappy screen ASCII sorry ------------------------------------ | | | |<-Screen | | | ^ | | | | | | | | |-------| | | . |<-Radar | ^ | . | ------------------------------------
KEY ^ = ship pick the location of the ship on the screen. now lets say you have a small radar well Lets say a ship is at 850x680 as showen by the ship at the very bottom or the 'screen' place the radar screen where ever. just an idea -I edit a lot. Prepare thyself. |
Tomoso
Member #3,128
January 2003
|
I added if (x > 10 && x < 110 && y > 300 && y < 419)
to the respected line, but I knew that wouldnt work since i tried it before . Sorry I didn't explain my problem more precisely. Lazy Noob - Blog |
BAF
Member #2,981
December 2002
|
Then you will have to take image width/height into account for the size of your square on the radar. psuedo code: radar_box_w = enemy_bitmap.width / radar_width radar_box_h = enemy_bitmap.height / radar_height // Then you have to check if it is on the screen at all if(enemy.x + enemy_bitmap.width > 0 && < screen width && same with y/height) if(enemy.x < 0) radar_box_w = enemy_bitmap.width - abs(enemy.x); // do the same with y / height /* then draw your rect with width/height of radar_box_w x radar_box_h. This may be all wrong or not what you're asking for, not sure. */
|
Tomoso
Member #3,128
January 2003
|
I don't understand what exactly your refering to when you say 'radar_box_w' and h. Lazy Noob - Blog |
BAF
Member #2,981
December 2002
|
radar_box_w and h are the width and height of the rect you draw on the radar. abs returns the absolute value of a number. It makes negative numbers positive and keeps positive numbers positive. |
Tomoso
Member #3,128
January 2003
|
Thanks BAF. I can't actually get to coding atm but I finally got round what your trying to say about the radar box thingie and am sure I can work it out when I get home. Lazy Noob - Blog |
|