Ok thanks, I was looking at the xLib tutorials and I figured out how to draw the map AND the player but I have some questions.
When I move the player, how should I draw the screen: only redraw the player or redraw everything including map? Oh and how should I clear the spot that the player was last at? ATM I have it redraw the Map then the player over and over in a while loop. This sucks up speed badly.
Drawing question
Moderator: MaxCoderz Staff
-
- Regular Member
- Posts: 83
- Joined: Tue 18 Apr, 2006 5:33 am
- Location: Washington->UC Berkeley '15
Depends if your 'Oring', 'ANDing' (Practically only used for masking), 'XORing', or overwriting the sprites. IF your overwriting, check the square your on, and redraw it to what it used to be before your dumbo character had to step all over it. There is no need to redraw the whole screen, just redraw where the location of the character now is. I don't even know if you're drawing masked sprites -_-.
Sorry, I don't use Xlib...
Sorry, I don't use Xlib...
basically if you redraw the sprite dirctly over the old sprite with xor logic, it will erase the old sprite. If you have grass or something where the person walks then you also have to redraw the entire map, its not too slow because asm is way faster than basic and then update the chars position, mask and then draw him. or just draw him if you do not use a mask.
you do not constantly redraw the person/map, i usually draw everything then go into a keypress loop. all it does is lok for keypresses
and you can usually counter any speed problems by making the person jump farther per keypress (if you are trying smooth scrolling)
and also if you still try to use the homescreen for games, i usually convert the outputted screen into a string first, then output the string, and then the player, and i only have to change the string when i change screens. its like a graph buffer.
you do not constantly redraw the person/map, i usually draw everything then go into a keypress loop. all it does is lok for keypresses
and you can usually counter any speed problems by making the person jump farther per keypress (if you are trying smooth scrolling)
and also if you still try to use the homescreen for games, i usually convert the outputted screen into a string first, then output the string, and then the player, and i only have to change the string when i change screens. its like a graph buffer.
-
- Regular Member
- Posts: 83
- Joined: Tue 18 Apr, 2006 5:33 am
- Location: Washington->UC Berkeley '15
Erase the old sprite? Xor logic inverts the the sprite below it, so if you putting the sprite on the on the screen, then if both pixels are set, they are undone, if one pixel is set (Doesn't matter which) then it will stay the same, and if both pixels are not set, they'll stay unset. This really screws with pretty backgrounds (don't use if you have a complex background). Goood thing about XOR logic is that you can undo what you have done by XORing the sprite right back on (which reinverts it back to normal).basically if you redraw the sprite dirctly over the old sprite with xor logic, it will erase the old sprite. If you have grass or something where the person walks then you also have to redraw the entire map
Use AND an OR log for masking sprites usually, if there is a pretty background that you don't want to overwrite. You have to save the background using this method sine it can't be undone..
No clue how to implement this in Xlib, but I can do it in assembly..
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am