Drawing question

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

wild8900
New Member
Posts: 35
Joined: Mon 19 Sep, 2005 11:26 pm

Post by wild8900 »

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.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

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...
jimmothy
New Member
Posts: 50
Joined: Sat 09 Dec, 2006 2:13 am

Post by jimmothy »

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.
wild8900
New Member
Posts: 35
Joined: Mon 19 Sep, 2005 11:26 pm

Post by wild8900 »

Nah im past output() homescreen games ;P
Thanks for the tips, btw, how do you use masks? those would really help.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

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
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).

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..
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

It can be done in xLIB, store it as a picture! its not really fast though
User avatar
crzyrbl
Calc Wizard
Posts: 518
Joined: Wed 06 Jul, 2005 4:56 pm
Location: 3rd rock....

Post by crzyrbl »

gravity? does your samus actually accelerate downwards, or does she just move down once every tick if she can?
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.

Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Its pretty easy to go down in increasing steps, as far as you can (well the last bit complicated, when you have to figure out how far you have to go back when you fall through the ground - which will happen)
maybe a 'while' loop counting back up until "underTheGround" is no longer true?
Post Reply