#16
Posted 20 April 2014 - 09:31 AM
Do you think you might be up to that Zecora?
#17
Posted 20 April 2014 - 10:14 AM
Waitdraw only runs the internal code allowing things to update for this frame up to drawing which is the last thing that happens. If you want to incorporate changes that happen the current frame such as Link's Movement and current Action you'll need make your changes after calling Waitdraw and still call Waitframe at the end of the loop; or at the beginning, since it actually doesn't matter. Just don't do this unless your using a do loop.while(true); //Always cause ZC to freeze with the exclusion of do loops.
A do loop? I didn't even know zscript had do-while, but how should that make a difference anyway?
#18
Posted 21 April 2014 - 12:22 PM
Does someone have an example of a solid FFC?
Edited by anikom15, 21 April 2014 - 12:22 PM.
#19
Posted 21 April 2014 - 01:05 PM
The idea is that when Link steps onto an FFC, you can determine whether he moved vertically or horizontally based on the proportions of the intersecting rectangle (i.e. whether its width or height is greater) and reposition him accordingly.
// Set this to 1 if you're using the big Link hitbox, 0 if not. const int SOLIDFFC_BIG_LINK = 0; ffc script SolidFFC { void run() { int hitboxAdjustment=0; float xOverlap; float yOverlap; if(SOLIDFFC_BIG_LINK==0) hitboxAdjustment=8; while(true) { if(Link->X+16>this->X && Link->X<this->X+16*this->TileWidth && Link->Y+16>this->Y && Link->Y+hitboxAdjustment<this->Y+16*this->TileHeight) { if(Link->X<this->X) xOverlap=Link->X+16-this->X; else xOverlap=this->X+16*this->TileWidth-Link->X; if(Link->Y<this->Y) yOverlap=Link->Y+16-this->Y; else yOverlap=this->Y+16*this->TileHeight-(Link->Y+hitboxAdjustment); if(xOverlap<yOverlap) { if(Link->X<this->X) Link->X=this->X-16; else Link->X=this->X+16*this->TileWidth; } else { if(Link->Y<this->Y) Link->Y=this->Y-16; else Link->Y=this->Y+16*this->TileHeight-hitboxAdjustment; } } Waitframe(); } } }
#20
Posted 22 April 2014 - 08:29 AM
I love you Saffith, just marry me already damn it.
#21
Posted 22 April 2014 - 10:49 PM
#22
Posted 22 April 2014 - 10:55 PM
#23
Posted 22 April 2014 - 11:12 PM
#24
Posted 22 April 2014 - 11:27 PM
#25
Posted 22 April 2014 - 11:37 PM
I mean you'd have to change the whole thing to a function that checks each FFC every frame rather than an FFC script.
#26
Posted 23 April 2014 - 05:47 AM
int globalSolidFFCs[32]; int gSolidFFCCount; void MakeFFCSolidThisFrame(int ffcID) { globalSolidFFCs[gSolidFFCCount]=ffcID; gSolidFFCCount++; } void DoSolidFFCs() { ffc f; for(int i=0;i<gSolidFFCCount;++i) { f = Screen->LoadFFC(globalSolidFFCs[i]); SolidFFC(f); } gSolidFFCCount = 0; //reset }Simply call "MakeFFCSolidThisFrame()" from the ffc script, and "DoSolidFFCs()" from the global script. "SolidFFC" is simply the function that Saffith posted as a global function that takes the ffc as an argument instead of an ffc script.
With this setup all FFCs can be mad solid at will with a single function from any other script.
Improvement: I can't remember if you can make an ffc array global or not. If so just make the array hold ffc pointers instead of ids.
On the topic of pixel rendering that is not quite right: This can actually be tested by disabling blending, setting all Matrix transformations to Identity and creating a projection that maps all texels to pixels with a ratio of 1:1 (eg; orthographic). If you were to draw a repeating 16x16 image, treating the screen as a 16x16 grid of tiles, using rectangle coordinates of x,y,+15,+15, there would be single pixel gaps between them, and rightfully so. What's worse is you would be 'smooshing' 16 pixels worth of texels into 15 pixels worth of space which would look very bad. Even if you tried using a translation between 0..1 it would still look bad even at 0.5.
#27
Posted 23 April 2014 - 11:06 AM
I've run into my fair share of problems because of Waitdraw() placement. I think that we could use a good tutorial on when, how, and why to implement things either before, or after, Waitdraw().
Do you think you might be up to that Zecora?
Sure, I'll work on it once I get home.
#28
Posted 23 April 2014 - 11:31 AM
On the topic of pixel rendering that is not quite right: This can actually be tested by disabling blending, setting all Matrix transformations to Identity and creating a projection that maps all texels to pixels with a ratio of 1:1 (eg; orthographic). If you were to draw a repeating 16x16 image, treating the screen as a 16x16 grid of tiles, using rectangle coordinates of x,y,+15,+15, there would be single pixel gaps between them, and rightfully so. What's worse is you would be 'smooshing' 16 pixels worth of texels into 15 pixels worth of space which would look very bad. Even if you tried using a translation between 0..1 it would still look bad even at 0.5.
In that case you are using a different model for drawing. You are now specifying points (i.e. the cartesian coordinates of a surface) as opposed to pixels directly. OpenGL or any 3D system uses points which makes sense in that context, but in traditional 2D rendering (that is, before 3D cards and in the case of Allegro, SDL, etc.) graphics are drawn by the pixel in the manner I described earlier.
Edited by anikom15, 23 April 2014 - 11:33 AM.
#29
Posted 24 April 2014 - 09:19 AM
I believe Gleeok was talking about Pixel Rendering in the case of modern libraries not ZC itself. Also I'm currently swamped and will not be able to write a tutorial on Waitdraw for some time. Sorry guys
#30
Posted 03 June 2014 - 06:19 PM
Moosh used Solid FFCs in his Link's Quest for the Hookshot 2. It's actually a creative thing to use.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users