|
Problem initializing a character... Displaying 21-33 of 33 total.
prev
1 2
CrazyAznGamer
|
err, ok
// if you need to stop the camera from following the character...
// just put this line somewhere in the code
cameratracking = 0;
// this makes it track the player entity again
cameratracking = 1;
// if cameratracking == 0, then you can mess with the xwin and ywin
// setting xwin & ywin moves the top-left position of your screen in relation with the map
// thus, if you keep repeatedly calling this (presumably in a hookretrace)
xwin = entity.x[player_entity] - (imagewidth(screen) / 2); // note that player_entity is not a system variable :(
ywin = entity.y[player_entity] - (imageheight(screen) / 2);
// you would get some sort of cameratracking
// in any case, you can set xwin and ywin to anything
// so think about it and use it to suit your needs
EDIT: stupid me, I forgot about code tags being not supported here
Posted on 2007-02-24 17:06:17 (last edited on 2007-02-24 17:08:54)
|
zonker6666
|
Arkhan - a possible solution for you ...
say your map is calling the function startmap()
at the start of startmap() call HookRetrace("");
that will mean there will be nothing hooked (of course)
then just make your own main loop in which you would do the following ,....
int levelbuffer=NewImage(1,1);
void mymainloop()
{
int done;
FreeImage(levelbuffer);
levelbuffer=NewImage(curmap.w,curmap.h);
SetClipRect(0,0,ImageWidth(screen)-widthofoverlay,ImageHeight(screen), levelbuffer);
while(!done)
{
if(key[SCAN_ESC]) done=1;
RenderMap(0,0,levelbuffer);
TBlit(xwin,ywin,levelbuffer,screen);
ShowPage();
}
}
note --- theres a lot more that needs to go into that of course - but it should give you a basic idea
let me know if it works out ;)
Posted on 2007-02-24 21:00:57
|
Arkhan
|
Quote: Originally posted by CrazyAznGamer
err, ok
// if you need to stop the camera from following the character...
// just put this line somewhere in the code
cameratracking = 0;
// this makes it track the player entity again
cameratracking = 1;
// if cameratracking == 0, then you can mess with the xwin and ywin
// setting xwin & ywin moves the top-left position of your screen in relation with the map
// thus, if you keep repeatedly calling this (presumably in a hookretrace)
xwin = entity.x[player_entity] - (imagewidth(screen) / 2); // note that player_entity is not a system variable :(
ywin = entity.y[player_entity] - (imageheight(screen) / 2);
// you would get some sort of cameratracking
// in any case, you can set xwin and ywin to anything
// so think about it and use it to suit your needs
EDIT: stupid me, I forgot about code tags being not supported here
I found that earlier and something didnt click, perhaps it did now...
HookRetrace("Overlay"); is what I am using......
inside of overlay would I redefine the window variables listed above?? :)
Posted on 2007-02-24 22:00:42
|
CrazyAznGamer
|
2 zonkers:
Whoa, that's cool. It kinda scares me though... I think I'll stick with hooks. :D
2 arkhan:
Yessah, after you set cameratracking to 0 of course.
I'm doing something similar in some very cute-related code...
*cough* *cough*
Posted on 2007-02-25 01:46:27
|
Overkill
|
You'd put that code in your Overlay function. HookRetrace makes whatever function is supplied as its argument get hooked, and called every instance that the map is rendered. When someone says in a hookretrace, what they actually mean is your function that is called by HookRetrace(). So every time you draw the map, you'll want to correct the camera coordinates. xwin, ywin, and cameratracking are builtin variables, which you can use in your hooked function.
Experiment more, even if you're slightly confused by the process! Fiddle around, since it's better to only ask for help when you actually need it. Try doing what you think would work first, and then if it doesn't, we can help you out more effectively.
I've also given you topics to look up in the documentation that explain the various things you're interested in addressing. Read and research them! If you don't understand something after you've read it, ask, and be specific about what you don't get. Try looking at demos too, of course, they're often caked with nifty stuff.
Nothing personal, just seems like you're a little reluctant to try things out for yourself. :D
Hmm... Actually though, it makes me wonder, maybe a tutorial on using the Hook functions could be written...
Posted on 2007-02-25 01:57:42
|
Gayo
|
You can only hookretrace a single function, but that function can be as complex as you please, so it can call lots of other functions and make use of global vars and so forth.
entity vars are here and camera vars are here.
Posted on 2007-03-01 14:30:29
|
Arkhan
|
Ok Ive messed with this for about an hour now and not one thing has changed at all.
Here is the exactsituation:
When walking down, once the camera scrolls to that certain point, it will stop scrolling, but the overlay covers up whatever is under it...I need it to continue scrolling up so I can see where im going....
also if I walk into a town where they enter from the south border, I need the camera to be set so that when they show up, theyre not covered by the overlay.
Ive messed with the camera variable stuff for a long time now, and everything ive done hasnt done ANYTHING. Not a single change....
Posted on 2007-03-01 18:07:40
|
Overkill
|
Would you mind posting the code you're using in your hookretrace? I need to get an idea of what's wrong.
Posted on 2007-03-01 18:58:39
|
CrazyAznGamer
|
if I remember correctly, Kildorf did this
// uncatchcam!
// Demonstrates how to "uncatch" the cam: the screen will continue on scrolling when you
// near the edge of a map, so the player is always in the middle of the screen.
//
// This isn't really "drop-in"able... you'll have to take a look at the source and figure
// out exactly how it will work with your other stuff, especially retrace code.
//
// Yet another mostly useless map trickery from Kildorf.
It was in a news post sometime back not too long ago.
Actually, I'll put it as a little function for you to use (adapted from Kildorf's code, of course.)
void uncatchcam() { // call this inside a hookretrace or somethin'
int img, nx, ny, ex, ey;
int scrx = ImageWidth(screen);
int scry = ImageHeight(screen);
ex = entity.x[p] + (entity.hotw[p]>>1); ey = entity.y[p] + (entity.hoth[p]>>1);
if(ex < scrx>>1 || ey < scry>>1 || ex > curmap.w - scrx>>1 || ey > curmap.h - scry>>1) {
img = duplicateImage(screen);
// clears the screen
rectFill(0,0,scrx,scry,0,screen);
nx = 0; ny = 0;
if(ex < scrx>>1) nx = (scrx>>1) - ex;
else if(ex > mapx - (scrx>>1)) nx = mapx - (scrx>>1) - ex;
if(ey < scry>>1) ny = (scry>>1) - ey;
else if(ey > mapy - (scry>>1)) ny = mapy - (scry>>1) - ey;
blit(nx,ny,img,screen);
freeImage(img);
blitEntityFrame(((scrx-entity.hotw[p])>>1),((scry-entity.hoth[p])>>1),p,entity.frame[p],screen);
}
}
I'm not gonna pretend that the code is completely understandable at this point. However, I will point out that >>1 (which is bitshifting integers 1 to the right) is the same as dividing by 2, and that the "p" variable would point to the player entity (though you should rename it and adapt it to your own uses). This code isn't perfect, and I *anticipate* that the line with the blitEntityFrame() isn't needed (comment out that line and test it for me if you want, as I'm too lazy to mess with Kildorf's code XD)
EDIT: Note that he says it's not drop-in-abble. It's not. :( But the quick hack above *hopefully* should work nevertheless.
For most purposes, I would actually just make the map larger though. I mean, that versus using the function above XD.
EDIT2: Note to self and everyone else: camx and camy CAN'T MOVE the screen off of the map!
Posted on 2007-03-02 02:01:29 (last edited on 2007-03-02 02:17:22)
|
Arkhan
|
my hook retrace has a function that blits the overlay to the bottom mof the screen, and then i fiddled with different ways of changing xwin and ywin.....no matter what i stuck in (I made xwin = 9348) , nothing was different.
I messed with the cameratracking and isscrolling variables and made them 0's and 1's, and that didnt effect anything either....
that uncatch the camera thing is exactly what I want to do. ill try it when im home.
EDIT: also erm.....what is my player entity? I have int player = 1; in my system VC. is that what I want? Or did I miss something...as usual ;)
Posted on 2007-03-02 12:40:53 (last edited on 2007-03-02 12:44:57)
|
zonker6666
|
Arkhan - im pretty sure that xwin and ywin are made to
be limited so that the map can never be offset enough that you
would see the void beyond.
What I would do is simply use a different set of variables :)
just make yourself 2 global vars called xoffset and yoffset
then RenderMap(xoffset,yoffset,yourmapimg);
and replace the code that u have now to modify the values of xwin and ywin to modify these 2 (xoffset and yoffset that is)
Posted on 2007-03-02 14:00:48
|
Overkill
|
Actually, rather than replacing the map system like zonker suggests, you could, uhm, just make the box move to the top whenever the player's at the bottom of the map, or just add the necessary extra obstructed area so that they don't go under the box as you originally thought of doing! ...I don't know why I hadn't suggested that again, because your original idea of adding a few extra tiles at the bottom of your maps would work.
Posted on 2007-03-02 15:02:21 (last edited on 2007-03-02 15:03:47)
|
Arkhan
|
Yeah I dont want the box to go up top. Thats wanged out. :)
Ill just make the map longer......its probably less work in the long run...
Posted on 2007-03-02 20:31:47
|
Displaying 21-33 of 33 total.
prev
1 2
|
|