YolkfolkThe Dizzy Fansite 0 logged in0 playing
Community discussion

DizzyAGE General Coding Queries

Started by delta on 9 February 2008 • 258,915 views

721 posts
#54127
I'm starting this thread because there's no-where to ask general questions people may have about coding in DizzyAGE.

so... my question is, is there any way of putting an animated tile onto the HUD? i tried using the same code it uses to display the lifebar tile, but the tile just stays at the first frame.

any thoughts? it's not essential, i just thought it'd be nice.
👍 0
#59388
check the parameters for HudDrawTile in the docs
the last one is the tile's frame, so you'll have to advance it by hand
try like frame = GameGet(G_FRAME), I think it will be clamped at the
max tile's frames. If not, do that with a modulo operation (%maxframes).
👍 0
#59747

Hi. I've been poaching about with DizzyAge for a while. At first I was dreading about putting my fingers into script, but I have managed to achieve a few simple things. I was looking at PTeal's work on Magicland about killing the ghosts with the power pill (Hope you don't mind {yolkfolk}:dizzy: ) . But when I try to implement it from scratch myself, I am unsuccessful. Could someone explain how I can do this simply. Be gentle I'm far from dab hand, hopefully I'd be able to make my own fan game sometime {yolkfolk}:dizzy: .

👍 0
#59750

this is a fairly simple bit of code, but only when you know how!

you need to have the brush type of the 'ghost' set as dynamic, with the collider property set to 'call handler' so that it calls the handler when dizzy collides with it, and also set the Death property to a number (for example 1). this enables you to identify the ghost in the handler, and also enables you to have custom text should the 'ghost' hurt and kill you. You also need to have the Class property set to either hurt or kill. (oh and don't forget to give the 'ghost' an ID number.)

then you need to modify part of the HandlerCollision() function in the handlers.gs script file, to read something like the following code. i'll assume the powerpill is object ID 1000.

if(ObjGet(idx,O_CLASS)==CLASS_HURT && mode!=0) // hurt objects
{
if(ObjGet(idx,O_DEATH)==1) // death cause is ghost
{
if(InventoryFind(ObjFind(1000))!=-1) // powerpill is in the inventory
{
ObjSet(idx,O_DISABLE,1);
SamplePlay(FX_BEEP1);
return; // don't hurt
}
}
PlayerHurt(3);
if(PlayerGet(P_LIFE)==0)
PlayerSet(P_DEATH, ObjGet(idx,O_DEATH));
return;
}

compare the bit of code above with the HandlerCollision() function in the default handler. if the item has a class of 'hurt', what the extra bit of code does is firstly identify if the object collided with has a Death property of 1. if it does, then it then looks if the powerpill (ID 1000) is in the inventory. if it is, it disables the item you've collided with (the ghost), beeps, and stops the handler from going any further (using return; ). if either of those isn't true, it will bypass the extra code and harm the player.

👍 0
#59751
oh and don't worry about looking at other games and using part of the code, it's one reason why DizzyAGE is open-source, so that others can look, learn, and copy, in order to help them with their own games.
👍 0
#59752

Thanks I'll give it a go later on {yolkfolk}:delight:

👍 0
#59756

Also, make sure you go through the DizzyAGE book:
https://www.yolkfolk.com/dizzyage/books/dizzyage/page00_toc.html
There is basic stuff explained in there, enough for a simple game.
Once you get the basics, it will be much easy to get an idea about other puzzles.
And if you need more help, feel free to ask.
Alex

Have a look at the "How To" articles too:
https://www.yolkfolk.com/dizzyage/articles.html

👍 0
#59770

I've noticed a small error in the default game. at the top of game.gs, it says the function to use for custom death sequences is 'RespawnPlayer_DEATH()' where DEATH is the number of the P_DEATH/O_DEATH property.

only problem is, when seaching for this function, the player.gs file looks for 'PlayerRespawn_DEATH()', which, of course, it's never going to find...

took me quite a while to figure out why my custom death function wasn't working.... :tongue: needless to say, it now is.

along with 99% of the game. *is nearly finished* {yolkfolk}:yahoo:

👍 0
#59788
I'm not sure what you mean.
The code of the PlayerLoseLife() function that searches for the respawn callback does:

fid = gs_fid("PlayerRespawn_"+(str)death);
if(fid!=-1) call(fid);

where
death = PlayerGet(P_DEATH);


so the resulted callback name sould be like for example:

"PlayerRespawn_10" if you've been killed by a death type of 10

And so does work for me in TOS.
👍 0
#59794

yes it does work, my point is that in the game.gs file at the top, where it tells you what commands you can use, it calls it

RespawnPlayer_

which doesn't work, as i realised after about 15mins of trying to figure out why it wasn't being called. :tongue:

👍 0
#59817

right. i have an issue.

if i want to move a player's position when he exits a room (for example to move him into a different room instead of the one he'd normally go into), i can use CloseRoom_rx_ry(). nice and simple, works with the code i have perfectly.

BUT can i instead use the HandlerRoomClose() to do it, as i'll be doing it with rather a few rooms, and don't want to have to manually call each one, i want to just check if he's in one of the rooms, then call the code.

i've tried, but it always positions him wrong, or actions the code multiple times. usually both. it's starting to annoy me, and i'm starting to think that the only way to do it is to code it for each room individually. i don't mind doing that, it'll just use a lot more code than i'd have liked. {dizzy}:huh:

👍 0
#59819

To reposition player when he exits a room,
you should use OutRoom_RX_RY() callback,
not the CloseRoom_RX_R().

And it should work to test rooms in the HandlerRoomOut handler.

Here is a piece of code (untested):

func HandlerRoomOut()
{
rx = GameGet(G_ROOM X) ;
ry = GameGet(G_ROOMY);
rw = GameGet(G_ROOMW);
px = PlayerGet(P_ X) ;
roomslist = { {10,1},{11,1},{20,2} }; // etc, could have it global too
for(i=0;i < sizeof(roomslist);i++) { if(rx==roomslist[0] && ry==roomslist[1]) // teleport room
{
if(px > = rx*rw) // exit right
{
// ....
}
}
}
// old handler code, for no teleports
// ....
}
👍 0
#59821
Hi !

Is there G_FADE property in a new DizzyAGE like in the older versions (e.g. TOS ) ? I searched through the books and scripts but found nothing. Thankx.
👍 0
#59824
G_Fade is an extra piece of code incorporated into certain games such as TOS, DWD, TTD, WWD and RRD, allowing the screen (and certain objects) to be faded out. It's mostly used to fade from the intro screen to the game screen.

the code isn't included in the default template as far as i'm aware.

the files it has code in are Utils.gs and Handlers.gs. see the code for the intro screen for any of the games i've mentioned to see the code used to implement it, and compare the utils.gs and handlers.gs files in any of those games with the same files in the default template to see which code you need to run it.
👍 0
#59826

[quote data-userid="17" data-postid="59819"]

To reposition player when he exits a room,
you should use OutRoom_RX_RY() callback,
not the CloseRoom_RX_R().

And it should work to test rooms in the HandlerRoomOut handler.

Here is a piece of code (untested):

func HandlerRoomOut()
{
rx = GameGet(G_ROOM X) ;
ry = GameGet(G_ROOMY);
rw = GameGet(G_ROOMW);
px = PlayerGet(P_ X) ;
roomslist = { {10,1},{11,1},{20,2} }; // etc, could have it global too
for(i=0;i < sizeof(roomslist);i++) { if(rx==roomslist[0] && ry==roomslist[1]) // teleport room
{
if(px > = rx*rw) // exit right
{
// ....
}
}
}
// old handler code, for no teleports
// ....
}

[/quote]

yeah sorry i am actually using OutRoom. i have something very similar to that code, except it's in it's own function that's called from the handler.

the problem is that one of the functions it runs works fine when a single room OutRoom()calls it, but not when it's being called from HandlerRoomOut(). and i really don't understand why. it seems to be going out of bounds on a variable i have in there, but i don't see any reason why when it's effectively doing the same thing.

👍 0
#59827
maybe it's latent?
I don't know, I have to see the code
👍 0
#59828

[quote data-userid="17" data-postid="59827"]

maybe it’s latent?
I don’t know, I have to see the code

[/quote]

i'm now using the Out_Room() function on all the rooms for the moment to ensure that the room it moves you to is the correct one, without having to worry about nasty errors from the handler.

it works perfectly in one direction (going up), but when you go back down again it moves you 3 screens further down than it should, with no rational reason as to why... {dizzy}:huh:

this is the code i'm using. newx and newy are set beforehand to the new roomx and roomy coordinates:

roomw = GameGet(G_ROOMW);
roomh = GameGet(G_ROOMH);

oldx = GameGet(G_ROOM X) ;
oldy = GameGet(G_ROOMY);

px = PlayerGet(P_ X) ;
py = PlayerGet(P_Y);

//work out the pixel difference
diffx = (oldx-newx)*roomw;
diffy = (oldy-newy)*roomh;

//work out the new position
new_posx = px-diffx;
new_posy = py-diffy;

//set new position
PlayerSet(P_X,new_posx);
PlayerSet(P_Y,new_posy);

that in theory SHOULD work no matter what side of the room he exits. (the game sets a different newx and newy position depending on which way he exits the room)

thoughts?

👍 0
#59829
There might be a little problem with your code. consider this:
Player moves from room 0,0 into room 0,1
When the callback is called his y position is 136, actually in room 0,1
And you want to send him in room 0,2 instead of 0,1
Since ROOMY is still 0, your offset is
diffy = (oldy-newy)*roomh = (0-2)*136 = -272
and when you subtract it from py, you get
new_posy = py-diffy = 136-(-272) = 408
instead of the 272 you neded

-------------------------------
0 R_0_0 (current room)


-------------------------------
136 R_0_1 (current py)


-------------------------------
272 R_0_2 (desired new room)


-------------------------------
308 R_0_3 (resulted py and room)


This is because the G_ROOMX, G_ROOMY are computed
after the callback sets the eventual new player's position
and returns.

You can get the room coordinates that correspond to
current player's coordinates, like:
ry = py / roomh;

that's the room the player just walked into
and unless you change his position,
that's the room that is set in G_ROOMY

Alex

[EDIT]
when you run in situations like these, try using println to display values and see why they are wrong.
👍 0
#59830

YES IT WORKS!!!! {yolkfolk}:yahoo:

it turns out that piece of code was fine, didn't need to change it. what i did change however was how it worked out newy. i added 1 if he is moving up, and removed one if he was going down. that ties in nicely with what you were saying about the different rooms, and it actually works!

i have spent the last three nights trying to get this piece of code to work. now it does, i can move on to do other bits that are slightly (but only slightly) less complicated....

i know i said this about a piece of code in MSD, but i really haven't been that frustrated since coding DMD....

Thanks Alex! :smile:

👍 0
#59835
right, now i'm trying to get the game to do something every second. i'm trying to tie it into the gs_time counter, but can't seem to....

EDIT: it's ok, i managed to do it. :smile:
👍 0