PDA

View Full Version : DizzyAGE General Coding Queries



Pages : [1] 2 3

delta
09-02-08, 10:40 PM
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.

xelanoimis
10-02-08, 07:08 AM
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).

GGower
01-03-08, 11:25 AM
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 :v2_dizzy_smile:). 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 :v2_dizzy_happy:.

delta
01-03-08, 11:52 AM
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.

delta
01-03-08, 11:55 AM
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.

GGower
01-03-08, 12:12 PM
Thanks I'll give it a go later on :v2_dizzy_happy:

xelanoimis
01-03-08, 04:35 PM
Also, make sure you go through the DizzyAGE book:
http://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:
http://www.yolkfolk.com/dizzyage/articles.html

delta
02-03-08, 01:10 PM
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.... :p needless to say, it now is.

along with 99% of the game. *is nearly finished* :v2_dizzy_yahoo:

xelanoimis
03-03-08, 12:26 PM
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.

delta
03-03-08, 07:33 PM
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. :p

delta
06-03-08, 08:00 PM
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_confused:

xelanoimis
06-03-08, 10:20 PM
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_ROOMX);
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[i][0] && ry==roomslist[i][1]) // teleport room
{
if(px > = rx*rw) // exit right
{
// ....
}
}
}
// old handler code, for no teleports
// ....
}

Bazi
07-03-08, 10:31 AM
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.

delta
07-03-08, 11:09 AM
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.

delta
07-03-08, 06:18 PM
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_ROOMX);
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[i][0] && ry==roomslist[i][1]) // teleport room
{
if(px > = rx*rw) // exit right
{
// ....
}
}
}
// old handler code, for no teleports
// ....
}


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.

xelanoimis
07-03-08, 07:09 PM
maybe it's latent?
I don't know, I have to see the code

delta
07-03-08, 07:40 PM
maybe it's latent?
I don't know, I have to see the code

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_confused:

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_ROOMX);
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?

xelanoimis
07-03-08, 08:03 PM
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.

delta
07-03-08, 08:27 PM
YES IT WORKS!!!! :v2_dizzy_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! :)

delta
08-03-08, 11:24 AM
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. :)

delta
08-03-08, 05:54 PM
ok i have another question. if you have a dynamic object with collider set to 'hard collision', can you get it to recognise when dizzy is on that particular object? not just if he's on any object like that, but actually get the code to return the ID of the object he's stood on?

xelanoimis
09-03-08, 07:35 AM
The hard collision with dynamic objects only rises Dizzy on their top,
but you can still achieve what you need.

For example, you could add a test to see if such objects are located under Dizzy's position. Test if dizzys position (-1 or -2 on y) is inside such an object's bounding box (x,y,x+w,y+h).
Use the ObjPresentCount and ObjPresentIdx to enumerate dynamic objects from the current room, to avoid wasting cpu with all the objects in the game.

Another idea (probably better) is to "attach" a soft collider object that would call the script collide handler, on top of the hard collider, and move them together. So when you're standing on the hard collider, you're touching the soft one and get notified in the script Collide callback. Of course, by "attaching", I mean just placing such an object there, for each hard collider you need, and have the code moving them together (similar to the chain AI).

Alex

delta
09-03-08, 09:26 AM
hmmm i was thinking of doing something like on each update of the object, test if the player x and y position is within a 'box' area on top of the object. (say between objecty-20 and objecty, and also between objectx-8 and objectx+objectw+8)

i thought that would do it.

however i now have a couple of new problems (always problems with this game!)

if i animate the objects seperately to move up at different speeds, and dizzy is on top of them, he doesn't stay on top of them, he kind of moves 'through' them, and eventually falls out the bottom. i'm using the aiupdatebubbleszone() code from TOS act one.

the other problem is i'm trying to get each object to move at different speeds, using a O_SPEED set in the object properties, but that ai code doesn't like it...

i'm starting to think about scrapping that and writing my own code...

EDIT:: oh, also, using that code (and the aiupdatebubbles() code), if you try to move the objects to a different room, it seems to disable them, and i can't find where it does it. i THINK i know where it is, but i can't find how to stop it...

delta
09-03-08, 10:36 AM
hmmm i was thinking of doing something like on each update of the object, test if the player x and y position is within a 'box' area on top of the object. (say between objecty-20 and objecty, and also between objectx-8 and objectx+objectw+8)

i thought that would do it.tried it, and it works. :)


however i now have a couple of new problems (always problems with this game!)

if i animate the objects seperately to move up at different speeds, and dizzy is on top of them, he doesn't stay on top of them, he kind of moves 'through' them, and eventually falls out the bottom. i'm using the aiupdatebubbleszone() code from TOS act one.i set a similar query to the one above, and moved the player up the same speed as the object if it found him there. works too. :)


the other problem is i'm trying to get each object to move at different speeds, using a O_SPEED set in the object properties, but that ai code doesn't like it...still not got this to work yet :(


EDIT:: oh, also, using that code (and the aiupdatebubbles() code), if you try to move the objects to a different room, it seems to disable them, and i can't find where it does it. i THINK i know where it is, but i can't find how to stop it...somehow this now seems to work....

one other thing, does MaterialCheckFree() return 0 if the box moves out of the room(while the object is still in the room)? cause it seems to for me, and i don't want it to... :(

delta
09-03-08, 12:03 PM
is it possible to search for a material in the current room, without using IDs, just searching by what the material is?

this is the code i'm using, but i need to add something to the start of it to get it to search only in the current room...



func Find_SpawnMat()
{
for(i=0;i<3;i++)
{
for(id=9003;i<9006;i++)
{
idx = ObjFind(id)
if(BrushGet(i,B_MATERIAL)!=MAT_BUBSPAWN) continue;
if(BrushGet(i,B_STATUS)==0) continue;
x = BrushGet(i,B_X);
y = BrushGet(i,B_Y);
w = BrushGet(i,B_W);
h = BrushGet(i,B_H);
ObjSet(idx,O_X,x);
ObjSet(idx,O_Y,y);
ObjSet(idx,O_W,w);
ObjSet(idx,O_H,h);
ObjPresent(idx);
return;
}
}
}


i could just use BrushCount, and loop through every one until it finds one with the correct material in the current room, but i think that'd be too much bother (and very CPU-heavy) just to find three things in each room...

xelanoimis
09-03-08, 12:03 PM
Yes, the idea with checking the player in the object's update is better.

If you move a platform too fast (on vertical), default dizzy code doesn't keep up with it. For example if you move it with steps bigger than 4 pixels. So a special adjustment of the player's position is ok. Take care not to force him in collision with blocking materials (like in a wall or a ceiling).

About moving with different speeds, this means either moving at different steps or more updates (O_DELAY). Anyway your object update function should do it.

Consider the ObjPresent need. If you move an object from a different room, into the current one, it must be "presented" with that function. Maybe this is the case, I don't know.

The material map is valid only for the current room, and a little border around it. So the MaterialCheckFree() should be able to test coordinates little outside the current room, but not too far. You can add checks for the coordinates to test, before testing them if you want to limit to the current room.

Alex

delta
09-03-08, 12:12 PM
right, i've solved one issue but found another. the objects do appear in the next room, however the game seems to recognise the dynamic object that i use to spawn the objects as a 'hard' object (like a block), and stops the objects going any further when it hits them. surely a dynamic object doesn't write in the material mat, and therefore they should go straight through it?

xelanoimis
09-03-08, 09:39 PM
the game seems to recognise the dynamic object that i use to spawn the objects as a 'hard' object (like a block), and stops the objects going any further when it hits them. surely a dynamic object doesn't write in the material mat, and therefore they should go straight through it?

I really don't know what is the case there.
Objects don't interact with each other and don't know about their collision, unless you added some code to do that.
Dynamic objects don't write in material map.
Check the function where you move (update) these objects.
Maybe some function you use, does some unwanted tests.

Apep
09-03-08, 11:26 PM
In the category of coding queries,

Could someone please tell me what's wrong with this?




func UseObject_235(idx)
{
if(idx==ObjFind(128) && ObjGet(ObjFind(235),O_STATUS==0));
{
Message0(14,6,"MY TEXT\nMY TEXT");
MessagePop();
Message2(4,4,"MY TEXT\nMY TEXT");
Message2(8,8,"MY TEXT\nMY TEXT");
MessagePop();
Message0(14,6,"MY TEXT");
MessagePop();
Message2(2,2,"MY TEXT!!!!!\nMY TEXT");
MessagePop();
Message0(14,6,"MY TEXT");
MessagePop();
Message2(3,3,"MY TEXT\nMY TEXT\nMY TEXT");
MessagePop();
Message0(14,6,"MY TEXT");
MessagePop();
ObjSet(ObjFind(5000),O_DISABLE,1);
ObjSet(ObjFind(235),O_STATUS,1);
return;
}
else
{
DropObject(idx);
}
}


It's copied and pasted from my game.gs file(I changed the text so as not to give away any spoilers but the code is identical)
It comes up with this error

PARSER,0,0,"parse error"
Data\Scripts\game.gs:930

in this case line 930 is the line that says else

Bazi
10-03-08, 07:34 AM
Hi ! Simply remove the semicolon from the end of the third row (if ....).

Apep
10-03-08, 10:56 AM
Gah!

I can't believe I didn't see that.....thank you:v2_dizzy_smile:

You just saved me a lot of headaches.

delta
10-03-08, 11:33 AM
I really don't know what is the case there.
Objects don't interact with each other and don't know about their collision, unless you added some code to do that.
Dynamic objects don't write in material map.
Check the function where you move (update) these objects.
Maybe some function you use, does some unwanted tests.

ermm yeah i did add some code. the CheckMaterialFree() code (or something like that, i'm at work) which checks if the object is in a 'hard' material, and if dizzy is stood on top, checks if dizzy is in a hard material. it seems to be reading the dynamic object as a hard material. i'm gonna try something tonight anyway, i'll see if it works.

delta
10-03-08, 08:40 PM
right, i've solved one issue but found another. the objects do appear in the next room, however the game seems to recognise the dynamic object that i use to spawn the objects as a 'hard' object (like a block), and stops the objects going any further when it hits them. surely a dynamic object doesn't write in the material mat, and therefore they should go straight through it?

right, after a lot of messing around, i've determined that the dynamic object isn't to blame. it's the fact that the objects disappear when they move to the next room. this is the code i've used:



func Check_Material(idx)
{
x = ObjGet(idx,O_X);
y = ObjGet(idx,O_Y);
w = ObjGet(idx,O_W);
h = ObjGet(idx,O_H);

roomw = GameGet(G_ROOMW);
roomh = GameGet(G_ROOMH);
if(MaterialCheckFree(x%roomw,y%roomh,x%roomw+w,y%r oomh+h)!=0)
{
return 0;
}
return 1;
}


so if it finds a 'hard' material anywhere, i get it to make the object disappear using:



if(Check_Material(idx)==1) { ObjSet(idx,O_DISABLE,1); continue; }


the problem is that it's classing outside the current room as a 'hard' material. and is making them disappear. i tried putting a check in the AI code to see if the object was is the current room, and if not, not to check the code above, but it massively slowed the game down. :(

actually, i've just played around with it a bit, and i *think* it may be because the 'life' of the object expires just as it gets to the top of the screen. so it seems that for the moment, it's not a problem.

however it does bring me onto another problem i mentioned earlier:

is it possible to search for a material in the current room, without using IDs, just searching by what the material is? i need to place objects i can use in the code in certain rooms (well, all of them!), but they need to have set positions in each room, but not the same position in each room. so i thought if i set 'blocks' in each room that had a specific material, then searched for that mat in that room, i could then set the object to the same coordinates as the mat! good in theory, but can it be done in practice?

if i can get this problem fixed (and assuming the issue at the top of this (rather long) post is not a problem, the rest of this game will be a doddle to code.

xelanoimis
10-03-08, 10:04 PM
the MaterialCheckFree() only tests the material map and it has nothng to do with objects.

the code you posted has a problem when object gets out of the current room.
for example, if current room starts at a x=240, room's width is 240,
but the object has x=230 (is in the left room), you get:

x%240 = 230%240 = 230

when material is tested at this position this is in the right side of the current room, not in the left room (that would be -10)

as I said, the material map is from [0 to 239], with a small border for safety (below 0 and over 239).

You should adjust your test to perform inside the room.
or if the object is all outside it, to skip the test.

I'm not sure what you mean by
"is it possible to search for a material in the current room, without using IDs"
However, there might be simpler solution than to search for materials for positioning objects. Have some predefined positions, or at least have some dynamic objects and use their bounds. Searching for materials in a big area, is cpu expensive.

delta
11-03-08, 05:34 PM
yeah i think i'll set dynamic objects and use their bounds. i can then use the room variables to store the ID of the dynamic objects so i can link them to the room they're in without having to do a mountain of coding.

nice one! :tup:

delta
12-03-08, 07:58 PM
alex, in the Room Properties, there are 4 'name' properties, and 8 'number' properties. how are they numbered? is it:

0 - 3: named
4 - 11: numbered

or is it

0 - 7: numbered
8 - 11: named


in other words, if i set the first numbered variable in the map, then call it in the game, which number do i need to call?? :dizzy_confused:

Bazi
13-03-08, 07:39 AM
Hi !

Name and number properties are both numbered from 0.

Name prop.: 0 - 3
Number prop.: 0 - 7

And first number from editor from room e.g. 2,1 you get in the script in this way:

RoomGet( 2, 1, 0 );

delta
13-03-08, 11:45 AM
:v2_dizzy_confused2: how does it then know you're wanting a number property and not a name property?

Bazi
13-03-08, 12:35 PM
Hi !

This is only for number properties, you can reach them in run time, read and write them. But (due to what I see in scripts) names run in a different way. Look at the roomprops.gs file on RoomsLoadTexts() function. This is run when the map is loaded and this function calls RoomSetCustomText() callback from game.gs for each room and each text property of the room (if it is not empty) and you have to test input params of this function and then do what you want to.

So I think it's only read-only property from the map editor stored in dizzy.rt file and only at the time when the map is loaded. If you want to reach texts in run time, check first function I mentioned above and make your own read function from dizzy.rt file. Or maybe better, in the second function I mentioned above (callback), fill your own global table (array) and then read from it whenever you want.

Number properties you can read with RoomGet(rx, ry, idx - 0..7) and write with RoomSet(rx, ry, idx, value) and they are saved in the save *.gam files like object properties, so you don't have to take care of them - look at the file.gs script.

Hope I'm right and Alex will not hit me :v2_dizzy_confused2:

xelanoimis
13-03-08, 01:07 PM
Bazi is right. Thanks for assistance :)

Numbers are 0..7 read/write anytime, saved and everything else.
Texts are just for receiving some "stuff" in the game, when it starts.
How they are interpreted in the callback is up for each game.
For example, in TOS, I keep on the first text in a room, names of enviromental sounds.
Like: "underwater,forest" or similar, depending on what sounds I need and how many.
When the games starts, in the callback, I parce the line for each room, extract the sound names (they're more like audio shaders) and store relevant info in a big matrix of rooms, for later use during gameplay.

As a remember note, avoid extensive use of strings, especially per frame.
They are not too fast in DizzyAGE.
For work with strings see the default library in GS9

Alex

delta
13-03-08, 09:15 PM
done it! thanks! :)

gahhh it's just taken me about 2 hours to code that bit of the game. quite insanely complicated....

ah well. done now. :)

oooo i just had a thought... i think that's all the complicated coding done now. :)

except that the game crashes if you try to restart from the game menu.... :S

delta
21-03-08, 02:42 PM
right, i'm porting DMD to v2.1 of DizzyAGE, and am trying to get the game to load the map from a menu option (there will be the option of choosing which map you play with). it changes the map fine, however it simply displays it over the top of the old one, like it has 2 maps loaded. is there a way to 'unload' the previous map?

also i'm getting very strange errors when i close the game or try to restart it from the menu once i've changed maps. something to do with the objects or roomnames or other things

the most common one is this:

<img src="http://i63.photobucket.com/albums/h129/temptationfeeder/error.jpg">

xelanoimis
21-03-08, 03:11 PM
I'll check the map load procedure.
What you want to do, should work, but it wasn't tested before.
Please send me the data of your game (with the two maps, loaded from the menu) so I can be sure it will work for you.

delta
21-03-08, 03:29 PM
ok i'll do that now, providing my internet stays connected long enough to do so.

xelanoimis
21-03-08, 09:12 PM
I think I fixed the problem with loading new maps.
The old map was not cleared before loading the new one.
It should work in v2.2. I plan a beta soon.

delta
09-04-08, 08:21 PM
here is a bit of advice for anyone wanting to be able to change maps in their game.

there will come a point that you have to tackle the save/load game aspect. it helps enormously if you have the variable used saved in the Game defs, as the game defs are the first ones to be saved/loaded. you will therefore find that if you have it saved in the Player defs (don't ask), you will have to change it throughout your code.

after changing files.gs so that it recognises which map you are trying to save/load, you will probably find that it will only successfully save (and load) games if they are in one map. the other maps saved games won't save or load properly. you may find yourself hunting for a while trying to find out which part of the load/save code it is failing on, so i will point you in the direction of the LoadStaticBrushes and SaveStaticBrushes functions at the bottom of Game.gs, which also look at the map file.

if you haven't changed it here so that it recognises which map you are trying to save/load, the game will fail to load the other map.

bah.

xelanoimis
10-04-08, 09:15 AM
Thanks for spotting the issue.
I made a special thread about it, so you can provide more help there, if someone needs it.

delta
10-04-08, 07:21 PM
alex, v2.2 doesn't seem to like my 'fade' function. i'll have a play with it to see if i can get it to work, but it used to work in RRD until i changed it to v2.2

EDIT:: it's ok, i found the reason. i was still using the old way of finding a tile in the Drawfade functions...

Bazi
11-04-08, 08:03 AM
yes, I had the same problem, but the reason is not to use TileFind and use direct id access.

delta
04-05-08, 08:21 PM
right, i'm using PlayerPlayAnim(), and it's playing the animation fine, but when it stops playing it, dizzy freezes, and i can't do anything with him. :(

help! i've tried PlayerEnterScripted to break him out of it, but it doesn't work. (i'm using completely custom movement in The Lord of Darkness) :v2_dizzy_confused2:

xelanoimis
05-05-08, 05:25 AM
PlayerPlayAnim() is a latent function. It waits between animation frames.
So it must be called from a latent function too (not from updates or movement functions).

It's used in PlayerPlayDead function, so it works for it's purpose.

It also sets the player in STATUS_SCRIPTED mode.
Try calling PlayerEnterIdle() after it.

delta
05-05-08, 10:01 AM
no, calling PlayerEnterIdle still doesn't work. it's like it gets to the PlayerPlayAnim() point, plays the frames, then freezes and doesn't go any further in the code.

so how would i get the game to play an animation once in the movement, before going back to Idle?

delta
05-05-08, 12:32 PM
:v2_dizzy_yahoo: YESSSSS!!!!!!!!

:) one of the best feelings is when you code something, and you're really not sure whether it will work or not. but you try it, and it works FIRST TIME!!!

it's especially gratifying if it's something quite complex that DizzyAGE was never supposed to be able to support.

in this case, it's being able to pick up any item when you're not stood in front of it, merely at the side of it. i've done it before (the standing stone in MSD), but that used an invisible mat that you <b>were</b> stood in front of. this time i've managed it while dizzy is stood in thin air. the items don't need anything else near them, and i've managed to get it to work seamlessly :v2_dizzy_happy:

if any of the coders have a spare few mins and are curious, try it for yourself. it aint easy to figure out how to do it! (i'd already figured out how to drop items by the side of him. it was easier to work out how to drop the items, but harder to code, as you have to take potential Block materials into account.)

woooo i'm so chuffed atm! and listening to Black Sabbaths Paranoid when i worked it out just made it even better! :v2_dizzy_walkman:

Meph
07-05-08, 12:37 AM
just been playing and testing different features and i was doing so well but can't quiet get this very simple task..
Didn't want to ask as i was doing so well.. did the tricky stuff.

trying to get Dizzy to re-spawn out of danger.. unfortunately he keeps coming back in the same place.

i guessed i need to change some of the settings in the 'player' folder but every time i change something i just get errors messages when he dies..am i looking in the right direction?

xelanoimis
07-05-08, 08:52 AM
You can set a specific cause of death value, when you kill the player in that danger area:

Define a DEATH_DANGER1 (or similar) to a specific value, in gamedef.gs
When player dies there, set this in the player's P_DEATH property.

In game.gs you can add a coresponding death message in the PlayerDeathMessage function.

Then you write a PlayerRespawn_DEATH callback (replace DEATH with your death value number). There, you can reposition the player in a safe position, depending on where he entered in the death zone, etc.

Check more recent games (v2.2) for such examples. I don't remember if I have an example in the docs.
Someone who used this technique in his game, please post the name of the game, for Meph to check.

Colin
07-05-08, 11:22 AM
You can set a specific cause of death value, when you kill the player in that danger area:

Define a DEATH_DANGER1 (or similar) to a specific value, in gamedef.gs
When player dies there, set this in the player's P_DEATH property.

In game.gs you can add a coresponding death message in the PlayerDeathMessage function.

Then you write a PlayerRespawn_DEATH callback (replace DEATH with your death value number). There, you can reposition the player in a safe position, depending on where he entered in the death zone, etc.

Check more recent games (v2.2) for such examples. I don't remember if I have an example in the docs.
Someone who used this technique in his game, please post the name of the game, for Meph to check.


Yes, I used them in my game. you need to set your defines in gamedef.gs
the message calls are near the top in my game.gs

just search for this function "func PlayerDeathMessage( death )"

Oh! I also edited the player.gs for the respawning

so search for this function "func PlayerRespawn()"

I know Jamie used it as well in RRD, as that's how I found out how to do it!

delta
05-07-08, 11:49 AM
WOOOOOOOOOOOOO i've finally managed to make my Lord of Darkness character animate when turning around! :v2_dizzy_yahoo:

that may not sound like much of an achievement, but it's a top-down view, and getting the game to animate the character when turning from facing one way to facing the other, rather than just 'flipping' the character, has been an absolute nightmare.

i tried for bloody ages last time and couldn't do it. today it's taken me the last 4 hours to do it! FOUR HOURS! :O

oh boy am i glad that is now done! all the animation is now done, so the game has taken a big step forward, and it means that the demo version is still on schedule. :)

i'm off for some lunch now!

delta
26-07-08, 03:30 PM
alex, i've come across a small problem.

i'm hiding tiles behind each other, then moving them infront using


ObjSet(idx,O_LAYER,1);


in the code, so that the tile i want at the top is now on layer 1, above everything on layer 0.

that works fine if you just want to view the tile on screen, as it then shows it. however the issue that i have is that i need the game to then 'see' the tile that is showing on top, using



PlayerTouchObjectInRoom(idx)


the problem is that even after moving a tile 'up' a level to level 1, the game still 'chooses' the tile below it (using PlayerTouchObjectInRoom(idx) ), as in the 'stack' of tiles, the tile on top is still the tile on level 0.

i didn't notice this in the dungeons section of TLoD, however in the Archives section i'm using it for something slightly different, and it's causing a major problem.

to see what i mean, do a puzzle (or shake the bush with the key in) in TLOD demo, and then try to view the (now visible) item. you'll find that he tells you it's the tile UNDERNEATH the item, until you pick the item up and put it back down again, at which point that item becomes the tile at the top of the 'pile'.

any thoughts? how would i move a tile 'to front' or 'to back' using the code, as i can by right clicking on it in the map editor?

thanks.

p.s. i also tried leaving it on top, but disabling it, however that bit of code still 'sees' the tile, even tho it's disabled, and it tells you that you're looking at an item which actually isn't visible at that point....

delta
27-07-08, 09:26 AM
it's ok, i've worked out how to do it.

when he 'looks' at an tile, the game was cycling through the 'stack' of tiles he was in front of, and returning the first one it found, whether that was on level 1 or 0 or whereever.

so what i did was encase that cycle within another cycle, so that it is looking first for tiles on level 2, and if it doesn't find one, then looks on level 1, then on level 0.

works perfectly! :D

xelanoimis
27-07-08, 01:08 PM
Yep, that's the correct way to do it.

delta
07-09-08, 06:22 AM
Hi Alex, i'm wondering if there is any way to alter things about setup.exe?

for example how do i change the name of the file it points at (set to dizzy.exe). Can i also change the scroll image it uses?

I ask because i'm wanting to do that for TLoD, and it occurred to me that although you can create 'non-dizzy' games with DizzyAGE, you can't actually have the .exe file for the game named as anything other than 'dizzy.exe'!

xelanoimis
07-09-08, 06:04 PM
Yes, you can change the setup.exe

Check it with a resource editor (ResHacker) and you'll find the images and the GS9 script responsible for everything. You'll figure out the available functions and how they work. Of course the basics of GS9 are the same, and of course the functions from the game engine not available.

Also, one can create a different setup, to set what is needed, as long as it works similar and writes in the dizzy.ini (which by the way I think it can't be renamed for non-dizzy games - the engine loads it by this name now).

delta
18-09-08, 07:21 PM
Alex, when i go into the setup.exe, the png files can only be saved as some obscure file type, not actually as a png. how do i load them into GIMP (or the like), and then reload them back into the setup.exe?

xelanoimis
19-09-08, 07:05 PM
Here is how I've just tested it it worked:

1. Open the setup.exe in ResourceHacker
2. Choose to save all resources
(you'll have the images as Data_1.bin, Data_2.bin, etc)
3. Rename the one you want to edit to have the extension .png
(for example Data_1.png)
4. Edit it in Photoshop and save it. (or in Gimp)
5. Rename back to Data_1.bin
6. Choose "Replace other resource" in ResourceHacker and browse for your file, Data_1.bin
Select:
ResourceType=FILES
ResourceName=BACKGROUND.PNG (in this case)
ResourceLanguage= (empty)
Hit Replace
7. Save file as setup.exe and test the result.

This is how I did it now, but probably you can skip some steps or so.

Also, you should be able to add other images in the same way and access them in the script. Just put them all under the FILES "type folder". Use png format to minimize the app size (TGAs will not be compressed like in the .pak).

delta
19-09-08, 07:07 PM
ok, thanks! i'll give it a go...

delta
21-09-08, 03:44 PM
ok, i've done that, but the image is a different size. i've changed #def WNDW to reflect this, and replaced the setup.gs file with the changed file, but it's still showing the old width. what have i missed?

akk i've also changed every instance of 'dizzy.exe' to 'tlod.exe', but it only runs it when the game is called dizzy.exe.

do i have to restart my comp for the changes to take effect?

xelanoimis
22-09-08, 06:04 PM
It should work by changing the WNDW and WNDH defines to the sizes of your image. I tried to downsize the window from Visual C by recompiling the application and it worked. It should be the same with the Resource editor. Just make sure the file is changed right.

The Image also represents the transparency region through the magenta color.

The executable is launched with:
gs_launch(`dizzy.exe`);
Search it in script and change it.

But you'll have a limitation with the dizzy.ini and dizzy.pak, as I said before.
Unless you use a hexadecimal editor and change this name in the game executable (it should be there) - just take care not to set a longer name or it will be really bad.

delta
22-09-08, 06:53 PM
yeahhhh i've got it now! for some reason when i uploaded the script and compiled it, it didn't work. :v2_dizzy_confused2:

so i've just been editing it in res-hacker and compiling it. works a treat!

Thanks, that's another job ticked off the list!

delta
23-09-08, 06:00 PM
alex, i'm now looking to change the key that the 'run' feature uses. at the moment it's 'shift' on the keyboard. how would i change this to 'control' (avoids clashing with windows stickykeys)

at the moment the code i use is:

shiftpressed = KeyboardStatus(0x2A) || KeyboardStatus(0x36);

what would be the codes for the control keys?

also, what code would i need to use to ensure this feature works with a joystick?

Thanks!

xelanoimis
24-09-08, 08:46 AM
DizzyAGE engine supports 256 keyboard keys, followed by 10 buttons for mouse and then the joystick with16 buttons and 4 direction keys (the joystick HUT).

The codes for control keys are: 0x1D (left) and 0x9D (right) (hezadecimal values)
The code for the first joystick button:
256+10 = 266 (decimal value)
The next joystick button is 267 and so one.

For the default player's control the engine uses the HUT direction keys for walk and jump (and the joystick axes of course) and the joystick's button 1 for jump, 2 for action and 3 for menu.

So you can try with button 4 (code 269) but I can't tell now where this button is on my gamepad, or on other joystick models. Anyway I think the joystick buttons can be rearranged from the driver, in case their placement is not convenient for a player.

When you have this feature ready, send me a build and I'll test it on my gamepad (a thrustmaster model).

Alex.

[EDIT]
If other codes are needed, they are listed in the engine's C/C++ sources (Engine/Input) or in the editor.pak script files (keyboard).
Or I can upload the file here.

delta
24-09-08, 05:14 PM
thanks alex, what code would i actually use to incorporate code 269 into the coding?

would it be 0x10D?

xelanoimis
24-09-08, 06:18 PM
yes, and you can enter the integer numbers in any format, decimal or hexadecimal. For the engine it's the same.

For example colors are easy to enter in hexadecimal, like 0xff0000 for red (transparent in this case), because the color channels are more visible. But you can enter it in decimal too.

delta
24-09-08, 06:46 PM
thanks alex, i'll send you a message with a link to download the final beta version when it's ready (probably 4-8 days time). just really putting the final graphical touches to it, as well as the odd little coding tweak.

xelanoimis
28-09-08, 10:54 AM
IMPORTANT:

Forget about checking joystick buttons with the KeyboardStatus functions - it was accepting only keyboard values.

Get DizzyAGE v2.2.1 and use JoystickStatus(key) key=[0..19] and JoystickAxe(axe) axe=[0..7].

And it's best to use the button mapping options from the dizzy.ini (joystick_b3 in your case - for running). Some users may want to remap their buttons and the engine does use these custom values.

Just get the joystick_b3 value when you start your game and use it with JoystickStatus. It should be 3 by default, but as I said, someone may want to change it.

delta
25-10-08, 04:37 PM
right, i'm trying to get DizzyAGE to choose truly random numbers, rather than psuedo-random numbers as it does at the moment.

the issue is that 9 times out of 10, BTD will start with the same screen, rather than a random one. of course it does 'randomly' choose a screen, but it just isn't very random, due to the way computers choose random numbers.

i'm currently trying to think of a way to use the current time (in seconds) or the current frame to choose it, as it would be a lot less predictable that way. however it has to work for a range of numbers. so i can't just say 'pick whatever the second digit of the time is', as if you only want a range of 6 numbers, it wouldn't be much good if the game picked an 8...

hmmm....

delta
25-10-08, 05:19 PM
ok, so here is how to create a random number generator:

Define G_CURRFRAME in def.gs

then put the following code in the HandlerGameUpdate() function in handlers.gs:



GameSet(G_CURRFRAME,GameGet(G_CURRFRAME)+1);
if (GameGet(G_CURRFRAME)==60) { GameSet(G_CURRFRAME,0); }

the number 60 is an arbitrary number, you cannot call a random number higher than this. if you need to call a higher number, change 60 to a higher number

and put the following code in utils.gs:


/////////////////////////////////////////////////////////
//randomiser based on a game frame counter
/////////////////////////////////////////////////////////
func time_rand(num)
{
sec = GameGet(G_CURRFRAME);

// if number range required is lower than the 'frame' number,
// reduce that number in increments until it is lower
if (num-1< sec)
{
for(i=sec;i>num-1;i-=num)
rand = i-num;
}
else // else set the random number as whatever the 'frame' number is
{
rand=sec;
}
GameSet(G_CURRFRAME,60-sec);
return rand;
}

when called, this basically finds the current game 'frame' number. if it is lower than the random number range, it sets the random number as that, otherwise it reduces it in increments until it is lower, then sets the random number as the resulting number.


the beauty of this is that is really is truly random, as the frame counter changes so quickly that it's impossible to 'fix' it to the same number again and again. it depends on when various things in the game happen, rather than an in-game number generator. :v2_dizzy_happy:

unfortunately if you request another random number straight after, the frame count will not have moved on, so if the start number is the same, the resulting number will be the same too. Still working on how i can fix that...

EDIT:: thought of a way to do it. i added <b>GameSet(G_CURRFRAME,60-sec); </b> near the end, which has the effect of 'reversing' the number, ready for if there is a command calling it straight after. again, if you change the number '60' in the handler code, you will need to change it here too. :)

xelanoimis
27-10-08, 11:52 AM
DizzyAGE GS9 uses the standard random generator, available in C/C++ (probably the same as in any other languages). This generator should be enough for most of the games.

So in GS9, to get a random number, use gs_rand(range) for integers and gs_frand(range) for floats. Now these, as any other algorithms that a computer could use, are pseudo-random numbers, but due to the implementation they should look pretty random.

The random algorithms are based on a given seed number to start with, and they generate the next number based on the value of the last one (or the seed, for the first time). However the generation code is based on known mathematic formulas, to produce very different values.

In GS9 use the gs_srand(seed) to give the random seed. Now, if you set this seed to a fixed number, you will get the same sequence of random numbers each time you launch the game. That's why games usually initialize the random generator with a seed based on the current tick time, when the game application starts (you can get that with gs_time() in GS9).

This is standard for games, and it usually produces good results.

Now 9 out of 10 with the same result is not "very random". It might be something wrong.
Have a look at the example of gs_srand in the GS9 book, and do a small test at the begining of the game:

gs_srand(gs_time()); // variable seed
println(gs_rand(100)); // will print different numbers each time

By default, I think the random seed is initialized by the DizzyAGE engine in this way, with a time based value. I hope gs_time() reports the computer time in milliseconds as intended, not an internal counter starting from 0 :)

And if you are to use another random generation algorithm, have a look on the internet about how to do it. It isn't that complicated and it should work much better than your's. And of course it can be done in GS9 too :)

Alex

delta
27-10-08, 07:18 PM
gs_srand(gs_time()); // variable seed
println(gs_rand(100)); // will print different numbers each time


i did that in start.gs, but changing the 100 to 6, as that is the minimum 'random' range i need, and got the number 2 six times in a row, straight from the start.

having said that, now i'm getting random numbers. :)

xelanoimis
28-10-08, 05:33 AM
Well, with random numbers you could get the same values in a row - they all have the same probabilistic eights - though this is rarely happening in the Loto games :)

Anyway, if you want to avoid such situations (like 4-6 times the same value in a row) you could retry the generation a few times, until you like the results (remember last values).

delta
04-01-09, 06:18 PM
right, another point at which i'm stuck.

basically i'm trying to duplicate the Inventory coding.

I'm using a table at the moment, as trying to duplicate G_INVENTORY didn't seem to work.

basically the problem is that if i 'add' something to the inventory, then try to find it using the equivalent of InventoryFind(idx); it returns 0 value. every time. for every inventory slot.

hang on a mo...

never mind.... i was setting tham all to 0 value at the start, and when it was trying to place them there, it was only looking for slots with a value of -1, so wasn't adding them... It's now working perfectly :)

delta
14-03-09, 10:24 AM
alex, if i'm playing a game, and changing the map as i play (but not re-loading the map in the game), then i try to save the game, am i correct that it will produce a file error message when trying to save the static brushes?

cause it is doing.

Humbert
17-03-09, 10:36 PM
Forgive my stupidity here, but are global variables that I define in the "gamedef" file supposed to reload upon restarting from the menu? Cause they aren't.

I can easily get around this by setting them in the "start" file, but I would have thought that choosing 'restart' would reread all the variables from "gamedef".

Is this not the case? Am I just doing something dumb and putting things in the wrong place?

As I said, it's an easy workaround, it's just that I'm pretty sure I'm doing something wrong that is causing the error in the first place.


ETA:
Actually, even worse, it doesn't seem to be saving my variables in the 'save game' function at all...

A little help here? (This will absolutely kill my game dead - unless I disable the 'save/load' feature entirely, which I don't want to do...)

delta
18-03-09, 11:35 AM
if you're setting them as game variables (or even player variables) such as:

#def G_TEST 101
#def G_TESTER 102

etc, then it will reload them, save them, etc. automatically.

if however you're just using:

int test
int tester

etc, then you will have to manually reload then, and save/load then when loading the save game files. I'll post how to do this when i get back home tonight. It's not too difficult.

macon
18-03-09, 11:38 AM
Not sure of the answer to your first part but I always reset them manually as that is what I have had to do in other languages.

You have to save and load global variables yourself. In game.gs look for SaveUserData(file) and LoadUserData(file). Here you list the variables to be saved and loaded. The syntax is shown in the comments. Make sure you include the '&' in LoadUserData or it won't work. I missed it in my first game and it took me hours to discover why it wouldn't work.

Humbert
18-03-09, 02:13 PM
Thanks guys - crisis averted! I was panicking because it was an entirely unexpected issue that I stumbled across (I had one of those very early on too that nearly made me drop the whole thing, until I figured out what that one was).

I still reckon I'm doing something wrong somewhere that's giving me some of these issues, but I got the variables to load back in properly now. Phew!

Sorry to have to ask for help on such a basic issue! Doesn't bode well for my new game, does it? :v2_dizzy_tongue2:



Make sure you include the '&' in LoadUserData or it won't work. I missed it in my first game and it took me hours to discover why it wouldn't work.

I spent ages last night (I was tired and overdue for bed) agonizing over why a simple UseObject function wasn't working - I tried everything and simply couldn't get it to work. I was tearing my hair out.

Anyway, turns out I had accidentally typed a lower-case "u", i.e. "useObject". D'oh!

delta
18-03-09, 07:22 PM
right, here we go. I now try to set everything as game (or player) variables, so that i don't have to change stuff in the load/save function of files.gs

you can put them in either def.gs or gamedef.gs, but the latter is recommended so that as few files are altered from the default as possible (makes it easier for new developers to understand what's been done). this is a sample of my custom variables from IID:



#def G_ENTERX 101 // room entry pos X
#def G_ENTERY 102 // room entry pos Y
#def G_ENTERPREVX 103 // Save the players previous roomX pos when entering a room
#def G_ENTERPREVY 104 // Save the players previous roomY pos when entering a room
#def G_WATERX 105 // water entry pos X
#def G_WATERY 106 // water entry pos Y
#def G_FADE 107 // fade 0..100
#def G_SIGN 108 // sets the sign style for messages

#def P_LIFEBAR 64 // new lifebar
#def P_LIFEBARDEDUCT 65 // new lifebar
#def P_DLAY 66 // frame delay


using the above method, you don't have to reset them on game restarts (the game will auto set them all to 0 value), and they will automatically be saved and loaded in the files.gs file.

however the other way to set variables is as follows. you define them as follows in the def.gs or gamedef.gs file (the following is from RRD, with little notes to remind me of stuff):



int p_lifebar
int p_lifebardeduct
int g_timer_lasttick //don't save on savegame.
int g_sign //don't save on savegame.
int lp
int ls
int trsp
int whsp
int t1sp
int t2sp
int t3sp
int t4sp
int t5sp
int c1sp
int c2sp
int c3sp
int c4sp
int c5sp
int whro
int plsp
int truckspeed
int speeddelay
int truck


if you do it this way, you will have to insert the following code into the load game code (highlighted in red):



func LoadGame( file )
{
f = gs_fileopen(file,0); if(!f) goto fileerrorrecover;

val=0;
sz="";

// load id
if(!gs_filereadtext(&sz,f)) goto fileerrorrecover;
if(sz!="DIZZYAGE") goto fileerrorrecover;

// load game id
if(!gs_filereadtext(&sz,f)) goto fileerrorrecover;
if(sz!=GAME_ID) goto fileerrorrecover;

// load game data
for(i=0;i < G_MAX;i++)
{
if(!gs_filereadint(&val, f)) goto fileerror;
GameSet(i,val);
}

// load objects data
for(o=0;o < ObjCount();o++)
{
for(i=0;i < O_MAX;i++)
{
if(!gs_filereadint(&val, f)) goto fileerror;
ObjSet(o,i,val);
}
}

// load player data
for(i=0;i < P_MAX;i++)
{
if(!gs_filereadint(&val, f)) goto fileerror;
PlayerSet(i,val);
}

// load static brushes with valid ids
if(!LoadStaticBrushes(f)) goto fileerror;

// load music
music = -1;
musicpos = -1;
if(!gs_filereadint(&music,f)) goto fileerror;
if(!gs_filereadint(&musicpos,f)) goto fileerror;

// load user data
if(!LoadUserData(f)) goto fileerror;

// load lifebar data
if(!gs_filereadint(&val, f)) goto fileerror;
p_lifebar = val;
if(!gs_filereadint(&val, f)) goto fileerror;
p_lifebardeduct = val;

// load other variables
if(!gs_filereadint(&val, f)) goto fileerror;
lp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
ls = val;
if(!gs_filereadint(&val, f)) goto fileerror;
trsp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
whsp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
t1sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
t2sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
t3sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
t4sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
t5sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
c1sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
c2sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
c3sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
c4sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
c5sp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
whro = val;
if(!gs_filereadint(&val, f)) goto fileerror;
plsp = val;
if(!gs_filereadint(&val, f)) goto fileerror;
truckspeed = val;
if(!gs_filereadint(&val, f)) goto fileerror;
speeddelay = val;
if(!gs_filereadint(&val, f)) goto fileerror;
truck = val;

gs_fileclose(f);

// reload room
MusicStop();
MusicFade(0,3);
MusicPlay(music,musicpos);
TimerOnLoad();
GameCommand(CMD_REFRESH);
ObjPresentGather(); // refresh present list
SamplePlay(FX_RESPAWN);

OpenDialogMessage( "LOAD SUCCESSFUL!", COLOR_YELLOW );
return 1;

fileerror:
OpenDialogMessage( "FILE ERROR!", COLOR_RED );
gs_fileclose(f);
GameCommand(CMD_EXIT);
return 0;

fileerrorrecover:
OpenDialogMessage( "FILE ERROR!", COLOR_RED );
gs_fileclose(f);
return 0;
}


and the following into the savegame code (note these HAVE to be loaded and saved in the same order):



func SaveGame( file )
{
f = gs_fileopen(file,1); if(!f) goto fileerror;

// save id
if(!gs_filewritetext( "DIZZYAGE", f )) goto fileerror;

// save game id
if(!gs_filewritetext( GAME_ID, f )) goto fileerror;

// save game data
for(i=0;i < G_MAX;i++)
{
if(!gs_filewriteint(GameGet(i), f)) goto fileerror;
}

// save objects data
for(o=0;o < ObjCount();o++)
{
for(i=0;i < O_MAX;i++)
{
if(!gs_filewriteint(ObjGet(o,i), f)) goto fileerror;
}
}

// save player data
for(i=0;i < P_MAX;i++)
{
if(!gs_filewriteint(PlayerGet(i), f)) goto fileerror;
}

// save static brushes with valid ids
if(!SaveStaticBrushes(f)) goto fileerror;

// save music
if(!gs_filewriteint(MusicPlaying(),f)) goto fileerror;
if(!gs_filewriteint(MusicPosition(),f)) goto fileerror;

// save user data
if(!SaveUserData(f)) goto fileerror;

//save lifebar data
if(!gs_filewriteint(p_lifebar, f)) goto fileerror;
if(!gs_filewriteint(p_lifebardeduct, f)) goto fileerror;

// save other variables
if(!gs_filewriteint(lp, f)) goto fileerror;
if(!gs_filewriteint(ls, f)) goto fileerror;
if(!gs_filewriteint(trsp, f)) goto fileerror;
if(!gs_filewriteint(whsp, f)) goto fileerror;
if(!gs_filewriteint(t1sp, f)) goto fileerror;
if(!gs_filewriteint(t2sp, f)) goto fileerror;
if(!gs_filewriteint(t3sp, f)) goto fileerror;
if(!gs_filewriteint(t4sp, f)) goto fileerror;
if(!gs_filewriteint(t5sp, f)) goto fileerror;
if(!gs_filewriteint(c1sp, f)) goto fileerror;
if(!gs_filewriteint(c2sp, f)) goto fileerror;
if(!gs_filewriteint(c3sp, f)) goto fileerror;
if(!gs_filewriteint(c4sp, f)) goto fileerror;
if(!gs_filewriteint(c5sp, f)) goto fileerror;
if(!gs_filewriteint(whro, f)) goto fileerror;
if(!gs_filewriteint(plsp, f)) goto fileerror;
if(!gs_filewriteint(truckspeed, f)) goto fileerror;
if(!gs_filewriteint(speeddelay, f)) goto fileerror;
if(!gs_filewriteint(truck, f)) goto fileerror;

gs_fileclose(f);

SamplePlay(FX_COIN);
OpenDialogMessage( "SAVE SUCCESSFUL!", COLOR_YELLOW );
return 1;

fileerror:
OpenDialogMessage( "FILE ERROR!", COLOR_RED );
gs_fileclose(f);
return 0;
}


now there may be an easier way of doing this in v2.2 of DizzyAGE, but this is the code i used in v1.31, and it still works, so i carried on using it.

That deals with the save/load functions, and the last thing is to reset all the variables when restarting. For this, i make a function called ResetVar(), in which i include all the variables that need resetting on game restart, as follows:



func ResetVar()
{
lp = 0;
ls = 0;
trsp = 0;
whsp = 0;
t1sp = 0;
t2sp = 0;
t3sp = 0;
t4sp = 0;
t5sp = 0;
c1sp = 0;
c2sp = 0;
c3sp = 0;
c4sp = 0;
c5sp = 0;
whro = 0;
plsp = 0;

truckspeed = 0;
speeddelay = 0;
truck = 0;
}


then i call it using ResetVar(); somewhere in the BeginNewGame() function, as every new game has to go through this function to start.

I hope this is of some help.

xelanoimis
19-03-09, 07:40 AM
TO Humbert:
Yes, the game saves and loads global game variables (those accessed through GameGet, GameSet and using the mentioned defines for clarity), player's variables and dynamic objects' variables. What you declare as global script variables you must save (and load) yourself in the SaveUserData callback - see the docs:
http://www.yolkfolk.com/dizzyage/books/dizzyage/ref03_template.html#SaveUserData()
However, not all script variables must be saved and reloaded. Some of them could just be reseted to default values in the LoadUserData() callback (when the game is loaded). Depends on what you do with them.
The SaveUserData and LoadUserData callbacks are in game.gs to avoid chances to the default template - as Jamie said, they are called from SaveGame and LoadGame.

TO Jamie.
I'm not sure about the error you have when saving a modified map. If you change static brushes' normal properties (like material, visibility, etc) it should be fine. You shouldn't change their positions or sizes, especially placing them outside the room they're in (that's why they are called static). As for the error, I don't know what could cause it exactly - I have to see a log or an example.

delta
19-03-09, 06:18 PM
Alex i think it was just because i was changing the map brushes file while i was playing the game. I think it references it or something when saving, which was then throwing up an error because i'd changed it from what it was expecting.

whatever, i've had no problems since. Thanks!

xelanoimis
19-03-09, 06:56 PM
Oh, I get it! You were changing the brushes file, not the brushes properties from ingame. Yeah, of course it doesn't like that :)

IQ1000
15-05-09, 08:57 AM
Yikes! :(

Sometimes just looking at delta's questions makes my head hurt.

Cannot wait till I am as good as he is!

IQ1000
15-05-09, 09:38 AM
Oh,
while we are referring to "coding quieries", I have a few questions.
1) How would you make an dynamic brush follow the player? This is the code I have:

px = PlayerGet(P_X );
x = ObjGet(idx, O_X );
if( px < x) x-=4;
if( px > x) x+= 4;
ObjSet(idx, O_X, x );

Now I am not an advanced scripter yet, so if you would please keep the answers simple. Thanks. :)

xelanoimis
15-05-09, 12:23 PM
Yes, that is the idea.
However there are a few more details.

For example if you do as you said, and x is not multiple of 4, it will jump each frame around player's position. So I would use a proximity range, like: if(px < x-4) x-=4

You can use a smaller move step if you want it to move slowler than the player.
Also consider that the player is not updated every frame which also helps you adjust speeds. If you need to match player's updates, there is a "IsPlayerUpdate" function (see it in the default template).

For a more advanced way of "following player" you can check the implementation of Daisy following Dizzy in act 3 of "Dizzy and The Other Side". She considers the material map so she can walk on solid materials in the same way the player does.

Or you can have a look at the bird in act 1. It flies around on spline paths and attack player if in a special area.

Alex

delta
15-05-09, 06:41 PM
personally i'd just find the players position, and set the dynamic objects position as the same! (you can also offset it if you wish)

thus:



func UpdateRoom_01_01()
{
px = PlayerGet(P_X);
py = PlayerGet(P_Y);

idx = ObjFind(2000);
ObjSet(idx,O_X,px);
ObjSet(idx,O_Y,py);
ObjPresent(idx);
}


that's basically the way i've done it in IID and MSD.

delta
15-05-09, 06:43 PM
the bit of code alex meant is:

if(px < x-4) x-=4


it was cut off by the forum as it contained a < in the middle of text.

xelanoimis
15-05-09, 08:26 PM
Yes, you can do as Jamie said if you want to "link" the object to the player.
The other case was more of a "following", especially if player can move faster.

To Jamie:
I saw your signature and I instantly heard the Iron Maiden's song "The Rime of the Ancient Mariner". I know it's based on a known english poem but now I have to find my Powerslave disk :)

delta
15-05-09, 09:59 PM
yes i pulled it straight from the poem 'The Rime of the Ancient Mariner' by Samuel Taylor Coleridge. I've been looking through things trying to get puzzle ideas for CoTM, and although i doubt i'll use anything from that poem (have you SEEN the length of it?), i do quite like those verses, so i thought i'd put them as my signature. :)

IQ1000
16-05-09, 09:13 AM
Thanks for the help, but I think I'll have to fiddle around with it.

To Delta:
If your looking for ideas for your game in literature, here are some good titles:
1 Alfred, Lord Tennyson's "Idyll's of the King"
2 William Shakespear's "MacBeth"
3 Sir Walter Scott's "Ivanhoe"

IQ1000
16-05-09, 10:01 AM
OK,
I tried what Mr. Simion said, but the thing still won't move! :(
Not sure what is wrong.

xelanoimis
16-05-09, 06:11 PM
You can always use the "println" command to show debug info in log and in console (open console with ` key). Use key in console to write script commands. For example:

println( ObjGet(ObjFind([I]ID),O_X) );
You can also use this command to debug your code and find out if it gets executed as expected.

IQ1000
17-05-09, 06:22 AM
Wow! Did not know about that interesting tool! Thanks! :)

Maybe I can set the player's P_COINS on IID using this method...
( no way! don't want to ruin a perfect game)

delta
17-05-09, 09:18 AM
Wow! Did not know about that interesting tool! Thanks! :)

Maybe I can set the player's P_COINS on IID using this method...
( no way! don't want to ruin a perfect game)

tbh i didn't know you could do that either!

and yes, you can use it to set the coins level :p i just set my coins in IID to 900!

but of course, that would be CHEATING!

<img src="http://i402.photobucket.com/albums/pp106/eqixx/coins.png">

xelanoimis
17-05-09, 10:55 AM
with some skill you can even move the player where the coins are... though it's kinda long code for a console command line :p

delta
17-05-09, 11:09 AM
hmmm....



for(i=0;i< =ObjCount();i++) { idx = ObjPresentIdx(i); if(ObjGet(idx,O_CLASS)==5&&ObjGet(idx,O_DISABLE)==0) { PlayerSet(P_X,ObjGet(idx,O_X)); PlayerSet(P_Y,ObjGet(idx,O_Y)); Break; } }


would that do it? Granted you'd have to enter it for every coin, but it should work... i haven't tried it as the console doesn't allow you to paste code into it :(

that's an example of how much you learn as you code games. Alex told me about that when he was testing Diamond Mine Dizzy two years ago, and i didn't have a clue how any of it worked! Now i can type it out off the top of my head! :)

IQ1000
18-05-09, 12:23 AM
YEEHA!!!
I finally figured out my problem with the object following Dizzy!
I had been using RoomUpdate instead of UpdateRoom!
uggghh! That took forever to figure out!
Thanks for the help, Delta and Mr. Simion! :)

xelanoimis
18-05-09, 02:38 PM
Yeah Jamie, that's pretty much the idea :)
No need for ObjPresent thought.
Of course it doesn't catch coins disabled by default (those enabled by solving a puzzle or so). Not to mention something like PlayerSet( P_COINS, PlayerGet( P_COINS )+1 );

delta
18-05-09, 06:57 PM
Of course it doesn't catch coins disabled by default (those enabled by solving a puzzle or so). Not to mention something like PlayerSet( P_COINS, PlayerGet( P_COINS )+1 );

yeah i know it wouldn't, however it needs that, otherwise it would go back over the ones that you'd already collected!

delta
07-06-09, 02:55 PM
Alex, what does it mean in the Log file when it says



2 MEMORY LEAKS DETECTED :(

xelanoimis
08-06-09, 11:19 AM
It means that two memory blocks that were allocated are not deallocated. The thing is they can be allocated by the engine or, through the script, by the game. Doesn't it give more info about which 2 blocks?

Try to find out what you did in the script before the message started to show in the log. Or send me the game's data and I'll check it out. Could be a bug in the engine or something missing in the script. Anyway it should be resolved.

delta
08-06-09, 06:24 PM
no that's all the info it gives. I only noticed because i opened the wrong file by mistake, as i don't currently have log set to 'on'. I'll look into it at some point, and if it doesn't stop doing it i'll let you know.

delta
08-06-09, 07:30 PM
does this help:



----------------------------------------------------------------------
MEMORY REPORT (3734 Kb used)
There are 2 memory blocks registered.
----------------------------------------------------------------------
NO NEW ADDR ID SIZE FUNC LINE FILE CONTENT
1 0191c060 ffffffff 5184 R9_ImgCreate 38 .\Render\R9Img.cpp
2 019d6808 ffffffff 5184 R9_ImgCreate 38 .\Render\R9Img.cpp
----------------------------------------------------------------------
size = 10368 = 10368 (malloc) + 0 (new)
calls = 176382 (malloc) / 176380 (free)
calls = 42749 (new) / 42749 (delete)
----------------------------------------------------------------------
2 MEMORY LEAKS DETECTED :(
----------------------------------------------------------------------

xelanoimis
08-06-09, 09:22 PM
I think there may be a problem with one or two of your tile files. The leak is from the alpha mask that's created when loaded. Do you have an "(alpha failed)" message in log when tiles are loaded?

Anyway it shouldn't happen even with a buggy tile. It's best to send me the data so I can see exactly why it happens.

delta
08-06-09, 09:27 PM
no but i have a 'texture failed'.... i'll look at that now...

EDIT:: yeah that's fixed it. one of the tiles had been saved without changing the options in GIMP, so it wasn't loading properly in the map. i don't get the memory leaks now. :tup:

Meph
13-06-09, 12:02 AM
Got a windy question.

Is it possible to speed up the 'wind' brush? so instead of Dizzy gently moves up he goes a bit faster..

Is it a case of editing the wind section of the script ?

xelanoimis
13-06-09, 02:24 PM
There's a WINDPOW defined in def.gs - try that first.
In the "Check Player Wind" section of handlers.gs this define is used to push player up (decrease y coordinate), with a little random variation. You can adjust this formula too, if needed.

Lord Dizzy of Yolkfolk
13-06-09, 05:02 PM
How do you code to perform an action when Dizzy collides with something when hes walking, ie to make a brush move, also to make a prompt when he enters a room but that it only prompts the once.

Can anyone tell me why if there is a reason why I cant, like I dont have account privileges or something, why I cant post images on my posts, I click the insert image icon and nothing happens.

Meph
13-06-09, 06:03 PM
There's a WINDPOW defined in def.gs - try that first.
In the "Check Player Wind" section of handlers.gs this define is used to push player up (decrease y coordinate), with a little random variation. You can adjust this formula too, if needed.

:dizzy_cool:
Thanks!

Lord Dizzy of Yolkfolk
18-06-09, 07:44 PM
How do you insert an image/screenshot into a post. I keep seeking help on this and no one seems to beable to help. Surely with you guys on here someone will know.

Id thought it be simple click on insert image icon, find image and click to insert, but doesnt let you.

I maybe wanting to show progress of my new dizzy game soon im doing but I cant :v2_dizzy_frown:

Adz.M
18-06-09, 07:55 PM
Well basically, you have to upload an image onto an image hosting site like Photobucket (http://www.photobucket.com).

Then once It's uploaded, get the image's URL and paste onto your post and put at the beggining of the URL and at the end.

Sorry if any of It's confusing :)

delta
18-06-09, 08:05 PM
for example, either of the following bits of code will display the picture shown below. (You get the link from a picture uploaded to a photobucket account, or similar)

This is the HTML way of doing it, and is the actual HTML code to display a picture:

&lt;img src="http://i402.photobucket.com/albums/pp106/eqixx/cotm2.png"&gt;

The following code is the BB (Bulletin Board) Specific code, using square brackets:

&#91;IMG&#93;http://i402.photobucket.com/albums/pp106/eqixx/cotm2.png&#91;/IMG&#93;

Both will display the image as shown below, but i personally prefer the HTML way of doing it. :)

<img src="http://i402.photobucket.com/albums/pp106/eqixx/cotm2.png">

Meph
18-06-09, 08:12 PM
i just attach picture to the messages.. click on the 'paper clip' icon above.

delta
18-06-09, 08:15 PM
How do you code to perform an action when Dizzy collides with something when hes walking, ie to make a brush move, also to make a prompt when he enters a room but that it only prompts the once.

sorry, i would usually have replied to this sooner, but my coding head has been on the shelf for a while!

anyway, this is either rather easy, or quite complicated, depending how you look at it.

Basically you set a hidden object as a collider (object property COLLIDER=1), that when collided with (use function Collide_Object_ID_1() ) changes the COLLIDER property to 0 (NONE), and changes the status of the object you want to move (you can't move Static Brushes). Then in the Update_Room_RX_RY() function for that room, you have it checking the status of the object, and if it changes (for example to 1, when the player collides with the collider), then you move it using the same Update_Room_RX_RY() function. also check each time it's moved to see if it's got to where you want it to go. if it has, then change the status of it back to 0, so that it doesn't move anymore.

If this is a bit confusing, or you're still not quite sure, let me know and i'll provide some example code for you.

Lord Dizzy of Yolkfolk
18-06-09, 08:47 PM
Thanks guys with responding, appreciated, ive never heard of Photobucket, do I really need to upload the images somewhere first then to reference to. Is this because of memory.

Why cant you simply just insert like you would normally by clicking a picture icon, finding where its saved and then insert like you would in excel or word for example. Be much simpler.

Lord Dizzy of Yolkfolk
18-06-09, 08:56 PM
sorry, i would usually have replied to this sooner, but my coding head has been on the shelf for a while!

anyway, this is either rather easy, or quite complicated, depending how you look at it.

Basically you set a hidden object as a collider (object property COLLIDER=1), that when collided with (use function Collide_Object_ID_1() ) changes the COLLIDER property to 0 (NONE), and changes the status of the object you want to move (you can't move Static Brushes). Then in the Update_Room_RX_RY() function for that room, you have it checking the status of the object, and if it changes (for example to 1, when the player collides with the collider), then you move it using the same Update_Room_RX_RY() function. also check each time it's moved to see if it's got to where you want it to go. if it has, then change the status of it back to 0, so that it doesn't move anymore.

If this is a bit confusing, or you're still not quite sure, let me know and i'll provide some example code for you.


Thats ok, yours always really helpful and I wouldnt have been able to attempt to make one without the tutorials and bits of help. I believe I should beable to do to completion now as ive coded most of it & done most of the map. An example code I be honest is nearly always the best for me if you can so kindly to go with the explanation.

Thanks

delta
18-06-09, 09:03 PM
hehe the problem is that the internet isn't like Word or Excel! think of it like this. when you close Word or Excel, what you've done is lost, except if you save it. it's the same concept for the web. if you don't 'save' the picture somewhere, no-one else will be able to see it!

The real problem is that pictures are basically files. and files take up space on a web server. and space costs money. The webpages are files too, but they are text files, so take up a lot less space. Check on your computer the difference in file size between a text file and a picture file.

so most websites won't allow users to upload pictures (or will limit the amount), because they would take up too much file space. So specialist sites have arisen (like photobucket) that let you store photos there, which you can then link to.

Lord Dizzy of Yolkfolk
18-06-09, 09:06 PM
Cheers yes, knew had to be summat to that effect with memory :v2_dizzy_happy:

delta
18-06-09, 09:27 PM
ok, the example code.

we'll assume the following:

the 'collider' object is ID 2000
the 'moving' object is ID 2001
the room you'll be in is room 02_05 (Room 2 on the X axis and 5 on the Y axis)
the moving object will be moving from left to right, stopping at X co-ordinates 440.

First set a Dynamic Object in the map somewhere in room 02_05. set the Property ID to 2000, the DRAW property to 2 (mat) and the property COLLIDER to 1 (call handler). This is the collider. (i assume you want it hidden. set DRAW to 3 if you want it visible)

Set another Dynamic Object in the same room (around about X position 260), with Property ID set to 2001, property DELAY set to 4 and ensure property STATUS is set to 0 (it should be that as default). This will be the moving object.

the code:



func CollideObject_2000_1()
{
idx=ObjFind(2000);
ObjSet(idx,O_COLLIDER,0); // stops player colliding with the collider again

idx=ObjFind(2001);
ObjSet(idx,O_STATUS,1); // changes the status of the object to be moved
}



func UpdateRoom_2_5()
{
idx=ObjFind(2001);
if(!IsUpdate(ObjGet(idx,O_DELAY))) return; // sets a delay between frame updates using object property DELAY. The object will move way too fast without this line (try it!), and the speed can be changed by changing the value of object property DELAY in the map.

if(ObjGet(idx,O_STATUS)==1) // check the status of the item to be moved.
{
x = ObjGet(idx,O_X); // find X position of object to be moved and store in variable 'x'
x += 4; // add 4 to variable 'x'

if(x>=440) // check if variable 'x' is larger than we want it to go
{
x=440; // if it happens to be larger than 440, set it to 440
ObjSet(idx,O_STATUS,0); // changes status of object to be moved back to 0, as we don't want it moving any further.
}
ObjSet(idx,O_X,x); // change the X position of the moving object to whatever the value of variable 'x' is
ObjPresent(idx); // force the object to be present in the current room (a bit of 'failsafe' code)
}
}


that should pretty much do it. :)

you should be able to see from the UpdateRoom function that if the STATUS of the moving object is 1, then it will be moved right by 4 pixels every frame update. every time this happens, the code checks whether it is on or past 440 yet, and if it is, changes the STATUS to 0, so that the 'IF' statement checking the status becomes false and therefore stops moving the object.

Lord Dizzy of Yolkfolk
19-06-09, 03:02 PM
Thanks, I will see to put into practice when I get some time in due course.

Put into practice and working, just I changed to use Y coordinates instead.

delta
27-06-09, 10:19 PM
Alex,

is there an easy way to play game music without looping it?

i've figured out a way, but it's not an easy way - basically i'd pre-load the length of the music as a variable, and use the game timer to count the seconds, and when it's counted up to the number of seconds in the tune, it would stop the music.

i just wondered if there was an easier way?

macon
28-06-09, 12:45 AM
I think you need

HandlerMusicLoop() in handlers.gs

delta
28-06-09, 05:25 PM
ah yes, thank you!

t'will be most useful for the game i'm planning for next years comp! :p

Lord Dizzy of Yolkfolk
28-06-09, 06:10 PM
ah yes, thank you!

t'will be most useful for the game i'm planning for next years comp! :p


Blimey you do well, dunno how you manage to keep producing, already in the planning lol :v2_dizzy_clapping:

Dunno how you manage to keep getting the ideas, im dry now after doing the one.

I was debating whether to hold mine back to enter, could of actually added to it and spent time till then to make any adjustments or improvements where necessary...but then I wasnt really fussed and I thought I would rather go ahead to release so people could actually play it without waiting.

Surprisingly was within 2 months of the tutorials, that doesnt mean I be doing another anytime soon though lol

delta
28-06-09, 06:26 PM
it helps that i'm alternating between 'classic' games and TLoD-style games. That means that i get different ideas, which may not work in the game i'm working on at the time.

I've not yet finished a third of CoTM yet, but i've already got quite a few ideas for my next 'classic' game. i may even start it before i finish CoTM, in which case there will be a good chance that both will be released for the 2010 comp.

not only THAT, but i may even enter a third, smaller game too. Most likely similar to Treasure Tomb Dizzy, as i can't really fit that type of game into the main 'classic' game i'm planning.


I do know what you mean though, after i'd finished Dreamworld Dizzy, i did TTD too, and that exhausted all my ideas for the next 6 months. Give it a few months tho, and you'll start to get more ideas. :)

Lord Dizzy of Yolkfolk
12-07-09, 05:46 PM
Ive been playing about trying to get dizzy to ride a moving platform, now the platform is moving ok (back & forth), ive made it 'block' but dizzy just falls straight through it. Ive done the coding same as the tutorial for if your setting a moving bat for example, just im using a platform.

If anyone can give me an example code if you cant do it like that I would appreciate. Thanks.

delta
12-07-09, 05:53 PM
you can't make it 'block' material because it's a dynamic object (the material property doesn't work for dynamic objects). instead, set 'collider' to 2: Hard Collision.

that should do it. ;)

Lord Dizzy of Yolkfolk
12-07-09, 05:55 PM
Cheers, that was weird as I just worked out to do that playing around with the call handler before seeing your reply, thought had summat to do with it being dynamic. Thanks for quick response though, was just about to edit my question.

Lord Dizzy of Yolkfolk
18-07-09, 02:19 PM
Trying to make dizzy be transported using 'Dynamic Object', this is working for up and down movement, but how you do it for left to right movement.
Dizzy just goes straight through even using 'hard collision' :v2_dizzy_confused2:

delta
18-07-09, 09:20 PM
What do you mean 'transported'? If you're moving dizzy to a different location, use PlayerSetPos().

If however you're wanting a dynamic object to block him from walking left or right (as hard collision will do for up and down) then that is rather more difficult...

If it's the last one you're wanting, then I'll detail a few ways tomorrow night, as I'm currently in a hotel room in Great Yarmouth typing this on my blackberry!

I will warn you though, it won't be a simple coding job. More details of exactly what you're trying to do would help me to think which ways would be suitable.

delta
18-07-09, 09:23 PM
Unless of course you're just trying to move him on a lift, in which case just move the waypoints so that the lift moves sideways instead of up and down.

Lord Dizzy of Yolkfolk
19-07-09, 08:09 AM
I have been playing about using lifts on something else and I have got them working.

2 parts to get working on this however:-

This is for when an action is done it then triggers something that moves that Dizzy rides on until it stops. Even making obect 'block' and 'hard collision' dizzy just goes straight through it so doesnt move. Not using waypoints as the object doesnt continue moving. Object moving to where required is working just dizzy. I have to do the reverse so it can be ridden back which isnt working.

I get redeclaration error when coming back though on the func UpdateRoom even though I trying to use different func name for coming back.

Maybe I need code to actually move dizzy like the object moves (all be it in a standing position on the object), like use PlayerSetPos() but rather than reappearing somewhere else in the map it actually shows him moving with the object to that position. I dunno how to get around the redeclaration prob on the update room either.

Meph
19-07-09, 01:09 PM
Why on earth would anyone want to stay at Great Yarmouth... ??
Its a bit of a dump.... im only 15 minutes away so i know what im talking about lol but Lowe isn't much better.. just slightly. ;)

delta
19-07-09, 07:02 PM
so let me get this right, you're actually wanting to move dizzy in the code when he's on a lift that moves left/right?

on the face of it, it's easy. in the updateroom code where you move the list, you just use PlayerSet(P_X,PlayerGet(P_X )+4); as well, to move dizzy to the right at the same time (assuming you're moving the left by 4 pixels).

however, delving deeper into it, you'll find that this moves dizzy whenever the lift is moving, whether he's on it or not!

to move dizzy only when he's on the lift, i'd have a small invisible collider about 16x16 pixels big, placed just above the lift. Get the code to move the collider at the same time as the lift, and set it to Call Handler. then write the collider function for it, with the 'Enter collision' mode setting the status of it to 1, and the 'exit collision' mode setting the status of it to 0. Then check the status of the collider in the updateroom code, and if the status of the collider is 1, then move dizzy as well as the lift! :)

oh and i was in a hotel in great yarmouth because i couldn't get a room in Norwich. apparently there was a Jehovahs Witness convention this weekend...

Lord Dizzy of Yolkfolk
20-07-09, 05:34 PM
Think I need to be a bit more specific and clearer then see if what you have explained is still relevant in part as im thinking you have assumed its all on one screen.

Dizzy rides an object when needed to get to where required, its not a lift but what it is, is irrelevant for the purposes of the coding. Now the object goes across several screens and stops at required position. Dizzy also has to be able to ride this object back across the same screens.

The object doesnt continue moving, only moves from destination A to B and from B to A when returning. This is left to right or right to left movement depending if object is starting from point A or B.

What is working:-
When Dizzy actions the object, the said object moves across the screens from start point A and stops and correct finish point B.

What I cant get working:-
Is to make dizzy move with the object, ie riding the object, so it takes the player correctly to point A or B respectively.

I cant get the object to return because it goes across a number of screens and I have to do the UpdateRoom function to show the movement, I get a redeclaration error. This is because I have done the update room function for the movement A to B.

I thought once I had A to B working I could copy the code for the return B to A and just changing the coordinates but I cant due to the redeclaration error.


Help :D

delta
20-07-09, 06:59 PM
you can't redeclare functions. what you need to do is put the contents of both updateroom functions into one, and use object status and IF statements to get the game to use the correct piece of code.

e.g. if status of the lift is 1, then the game moves the lift from A to B, and if it is 2, it moves it from B to A. if it is 0, then it doesn't move it.

oh and what i explained is still relevant. you just need the same code in each rooms updateroom function. or you could create a new function (called, for example, Move_Lift() ) and call that from each updateroom function (using Move_Lift(); ). That would save you writing the same code for multiple rooms, however i may be complicating matters somewhat! If i'm not, then have a look at part 8 of the video tutorials for a small example of code optimisation.

Meph
20-07-09, 07:05 PM
Ah thats because Norwich is in high demand.. we're pretty busy you know ;)
i'll be there tomorrow evening in fact.

macon
20-07-09, 08:29 PM
As Jamie says both left and right is handled by the same function. what I would do is whem the moving object is actioned I would check which room it is in. If it is in the leftmost room I would set its status to the amount of pixels it would move by. If it is the right most room set the status to a negative movement value. eg. status is 4 if moving by 4 pixels to the right and -4 if moving left by 4 pixels.

Then in the update room the moving objects x coordinates is changed by adding its status. When it is not moving set the status to 0.

For the first part I would set Dizzy's co-ordinates to that of the moving object (taking an offset into account). This can be done in the room update at the same time as the moving object is updated. if the object is not moving then of course you don't do it.

Lord Dizzy of Yolkfolk
25-07-09, 02:11 PM
Yes I sort of deduced would have to become part of the same function using 'IF' statements which means without an example of code I wont beable to do I dont think. Ive not had time since to even attempt trying anything.

delta
25-07-09, 02:52 PM
ok, here we go:

we'll assume the 'lift' rides across rooms 1_1, 2_1, 3_1, and 4_1.
we'll assume the lift is ID 2000. Set the 'delay' property of ID 2000 to '4'. we'll also assume the left hand 'trigger' is 2001, and the right hand 'trigger' is 2002. each trigger should be about 16x16 pixels, and positioned where dizzy would be if stood on the lift object at the positions that are furthest left/right.
we'll also assume that the leftmost X position is 300, and the rightmost X position is 1100.



func ActionObject_2001()
{
lift = ObjFind(2000);
lefttrig = ObjFind(2001);
ObjSet(lift,O_STATUS,1); // set lift moving right
ObjSet(lefttrig,O_DISABLE,1); // disable left hand trigger
PlayerEnterScripted(); // stop player from moving dizzy
}

func ActionObject_2002()
{
lift = ObjFind(2000);
righttrig = ObjFind(2002);
ObjSet(lift,O_STATUS,2); // set lift moving left
ObjSet(righttrig,O_DISABLE,1); // disable right hand trigger
PlayerEnterScripted(); // stop player from moving dizzy
}


func UpdateRoom_1_1() { Move_Lift(); }
func UpdateRoom_2_1() { Move_Lift(); }
func UpdateRoom_3_1() { Move_Lift(); }
func UpdateRoom_4_1() { Move_Lift(); }

func Move_Lift()
{
lift = ObjFind(2000);
lefttrig = ObjFind(2001);
righttrig = ObjFind(2002);
if(!IsUpdate(ObjGet(lift,O_DELAY))) return; // slow the movement down by using the 'delay' property of the lift

// move lift to the left
if(ObjGet(lift,O_STATUS)==1)
{
x = ObjGet(lift,O_X); // find current lift X position
px = PlayerGet(P_X); // find current player X position
{
x += 4; // add 4 to current lift X position
px += 4; // add 4 to current player X position (this MUST be a multiple of 4)
if(x>=1100)
{
x=1100;
ObjSet(lift,O_STATUS,0); // stop lift moving
ObjSet(righttrig,O_DISABLE,0); // enable right hand trigger
PlayerEnterIdle(); // player can move dizzy again
}
}
ObjSet(lift,O_X,x); // change lift X position
PlayerSet(P_X,px); // change player X position
ObjPresent(lift); // force lift to be present in the room
}

// move lift to the right
if(ObjGet(lift,O_STATUS)==2)
{
x = ObjGet(lift,O_X); // find current lift X position
px = PlayerGet(P_X); // find current player X position
{
x -= 4; // subtract 4 from current lift X position
px -= 4; // subtract 4 from current player X position (this MUST be a multiple of 4)
if(x<=300)
{
x=300;
ObjSet(lift,O_STATUS,0); // stop lift moving
ObjSet(lefttrig,O_DISABLE,0); // enable left hand trigger
PlayerEnterIdle(); // player can move dizzy again
}
}
ObjSet(lift,O_X,x); // change lift X position
PlayerSet(P_X,px); // change player X position
ObjPresent(lift); // force lift to be present in the room
}
}


that should pretty much do it. :)

you can see in the updateroom functions that i call a seperate function called Move_Lift() so that i don't have to write all the code out 4 times. this is an example of optimising the code, and is fairly easy to do if the code is the same (or similar) in a number of different functions.

Lord Dizzy of Yolkfolk
25-07-09, 03:50 PM
Thanks Jamie, I will report back in due course with how im getting on in applying it.

delta
25-07-09, 04:04 PM
also, because the two 'actionobject' functions are very similar, it is also possible to optimise the code for them by using different variables, as so...



func ActionObject_2001() { Action_Lift(2001,1); }
func ActionObject_2002() { Action_Lift(2002,2); }

func Action_Lift(trigger,stat)
{
lift = ObjFind(2000);
trig = ObjFind(trigger);
ObjSet(lift,O_STATUS,stat); // set lift moving left/right
ObjSet(trig,O_DISABLE,1); // disable the relevant trigger
PlayerEnterScripted(); // stop player from moving dizzy
}


This way uses 10 lines of code to do the same thing as 16 lines of code before. Compare it to the two functions in my previous post to see how it works. :)

Lord Dizzy of Yolkfolk
25-07-09, 05:44 PM
Not that im making this too completed, honest lol...

but I need to move 3 parts, I know I can use different status numbers, ie you set the status numbers then when you action it finds them to move them but it only moves the last one in the code.

if you can show the above coding but moving more than one part (simultaneously) I would be very appreciative....


If your wondering why 3 parts, its because if I shrink the brush to fit to the grid as an icon by time I use it on the
map its all blurred and no good, so had to keep larger and fit together in the map.

delta
25-07-09, 06:47 PM
personally i'd say the easiest way to do it is to shrink it in an image editing program and keep it as one object, however, if this isn't possible then the code is below. i've only shown the one status bit, as the other one will be virtually identical, and you'll be able to see what i mean just from the first one.

i assume you want them to all move together, and to start and finish in the same X positions...



func Move_Lift()
{
lift1 = ObjFind(2000);
lefttrig = ObjFind(2001);
righttrig = ObjFind(2002);
lift2 = ObjFind(2003);
lift3 = ObjFind(2004);
if(!IsUpdate(ObjGet(lift1,O_DELAY))) return; // slow the movement down by using the 'delay' property of the lift

// move lift to the left
if(ObjGet(lift1,O_STATUS)==1)
{
x1 = ObjGet(lift1,O_X); // find current lift X position
x2 = ObjGet(lift2,O_X);
x3 = ObjGet(lift3,O_X);
px = PlayerGet(P_X); // find current player X position
{
x1 += 4; // add 4 to current lift X position
x2 += 4;
x3 += 4;
px += 4; // add 4 to current player X position (this MUST be a multiple of 4)
if(x1>=1100)
{
x1=1100;
x2=1100;
x3=1100;
ObjSet(lift1,O_STATUS,0); // stop lift moving
ObjSet(righttrig,O_DISABLE,0); // enable right hand trigger
PlayerEnterIdle(); // player can move dizzy again
}
}
ObjSet(lift1,O_X,x1); // change lift X position
ObjSet(lift2,O_X,x2);
ObjSet(lift3,O_X,x3);
PlayerSet(P_X,px); // change player X position
ObjPresent(lift1); // force lift to be present in the room
ObjPresent(lift2);
ObjPresent(lift3);
}


hope that helps.

Lord Dizzy of Yolkfolk
25-07-09, 08:39 PM
Thanks Jamie for all the help, starting to make some progress now I think, still some things not working right but its all moving as one now to where it should, I need to do some adjustments as it needs to be something that can be ridden at all times if/when required.

delta
25-07-09, 09:12 PM
Thanks Jamie for all the help, starting to make some progress now I think, still some things not working right but its all moving as one now to where it should, I need to do some adjustments as it needs to be something that can be ridden at all times if/when required.

that code should enable it to be ridden at any time. The only thing with that code is that you can't ride it from side A to side B, then get back to side A some other way and try and ride it to side B again. you have to ride it back from side B to side A first.

IQ1000
26-07-09, 05:13 AM
Wow... I'm glad you two got that straightened out. That was a good question, Lord Dizzy. I've oftened wondered the same thing.

I have a question about timing different things in my game. For instance, if I change Dizzy's color, code it to wait ten seconds, then change his color back, several things happen. Mainly everything else is put on hold while the game is waiting those three seconds. You cannot use the action key. There HAS to be a way to time things without messing everything else up.

Help please! :v2_dizzy_confused2:

[ here is my script:

func ChangeColor(color)
{
PlayerSet(P_COLOR, COLOR_RED);
WaitTime(3);
PlayerSet(P_COLOR, COLOR_WHITE);
}

]

delta
26-07-09, 08:59 AM
wow, what is it with everyone wanting to do really really complex things in their games?! :p

I'll look at this when I'm at my computer, rather than on my blackberry.

delta
26-07-09, 09:21 AM
one small thing in your script before i look at how to do it. You don't need the variable 'color' in func ChangeColor(color) because you're not using it. It would work perfectly well as func ChangeColor() instead.

you only need that variable there if you were to specify the colour when you called that variable (for example if you wanted to call it more than once, with different colours each time.)

if you were doing that, you'd do:



func ChangeColor(color)
{
PlayerSet(P_COLOR, color);
WaitTime(3);
PlayerSet(P_COLOR, COLOR_WHITE);
}


and call it using:



ChangeColor(COLOR_RED);


or



ChangeColor(COLOR_BLUE);


etc etc.

delta
26-07-09, 09:56 AM
Right, here we go. The first thing i'll say is that this is really quite complex. The main section of code (shown in black) is basically for inserting a background 'timer' into your game (such as is used for keeping track of the time in IID, RRD, etc.), and has been adapted a bit by me from some code alex wrote a year or so back. however the code i show you won't include the on-screen display of the time (as in IID, RRD etc), as you don't need to do that. What i will do is highlight in red the extra bits that i've added so that you're able to set a 3-second timer for changing his color.

you're lucky that i did something very similar in TLoD for the potion counter. Took me a while to get it to work correctly if i remember rightly! :p


in gamedef.gs, add this code to the 'Global Variables' bit at the bottom. (change the numbers if you've already defined something as variable 101, 102 etc):



// Global variables
// Those used in game logic are recomended to start from 100 up to 200 to avoid the ones used by the engine or the template
#def G_TIMERLASTTICK 101 // used to store tick of game time
#def G_TIMER 102 // used to store game time
#def G_HOUR 103 // hour count
#def G_MIN 104 // min count
#def G_SEC 105 // sec count
#def G_TIMEPAUSE 106 // used to check if timer is paused (set to 1 if in menu dialogs - timer won't then advance)
#def G_CHANGECOL 107 // stores if the game is counting down the 'colour' time or not. 1=on, 0=off
#def G_CHANGETIME 108 // stores the time elapsed in the 'colour' time.


in utils.gs, add the following code at the bottom:



/////////////////////////////////////////////////////////////////////////////////
// Gameplay time counter
/////////////////////////////////////////////////////////////////////////////////

// call on begin game callback (BeginNewGame) to reset timer
func TimerReset()
{
GameSet(G_TIMERLASTTICK,0);
GameSet(G_TIMER,0);
}
// call on load callback (LoadUserData)
func TimerOnLoad()
{
GameSet(G_TIMERLASTTICK,0);
}
// update, call on the game update handler
func TimerUpdate()
{
if(GameGet(G_TIMERLASTTICK)==0) GameSet(G_TIMERLASTTICK,gs_time());
timer_currenttick = gs_time();
delta = timer_currenttick - GameGet(G_TIMERLASTTICK);
timer = GameGet(G_TIMER);

if(GameGet(G_TIMEPAUSE)==0) // if paused using esc, pauses timer.
{
if(delta>0) timer += delta;
GameSet(G_TIMER,timer);
}
GameSet(G_TIMERLASTTICK,timer_currenttick);
}
// call with reference paramters to get the play time
func TimerGetTime( hours, minutes, seconds )
{
timer = GameGet(G_TIMER)/1000; // seconds
*hours = timer / 3600;
*minutes = (timer / 60) % 60;
*seconds = timer % 60;
}
// debug display of the elapsed time
func TimerPrint()
{
h=0; m=0; s=0;
old_sec_count = GameGet(G_SEC); // stores the old value of the sec variable to be able to check against the new value
TimerGetTime(&h,&m,&s);
GameSet(G_HOUR,h);
GameSet(G_MIN,m);
GameSet(G_SEC,s);

if(old_sec_count!=GameGet(G_SEC)) // check if the 'second' value has changed
{
if(GameGet(G_CHANGECOL)==1)
{
coltime = GameGet(G_CHANGETIME)-1; // reduce timer by 1 every second
GameSet(G_CHANGETIME,coltime); // change variable to store new number

if(GameGet(G_CHANGETIME)<=0) // if it gets to 0
{
GameSet(G_CHANGECOL,0); // stop this function by changing the variable back to 0
PlayerSet(P_COLOR,COLOR_WHITE); // change player colour back to white
}
}
}
}


in the BeginNewGame() function in game.gs, put the following code:


TimerReset(); // resets time counter


in the 'HandlerGameUpdate()' function in handlers.gs, put the following code:



//change time
TimerUpdate();
TimerPrint();


all you need to do then is to change your function:



func ChangeColor()
{
PlayerSet(P_COLOR, COLOR_RED); // sets player colour to red
GameSet(G_CHANGETIME,3); // sets timer to 3 seconds
GameSet(G_CHANGECOL,1); // starts timer counting down
}


that should do it. i don't think there's anything else...

Lord Dizzy of Yolkfolk
26-07-09, 10:46 AM
that code should enable it to be ridden at any time. The only thing with that code is that you can't ride it from side A to side B, then get back to side A some other way and try and ride it to side B again. you have to ride it back from side B to side A first.


Yes you have to do that obviously, ive removed the disable bit from the code so it can be ridden at all times if/when required....so got it all working now adding a prompt as well :v2_dizzy_thumbsup:

Took a bit of doing getting the alignment as they actually had to start and finish from slightly different points. Never would of done it without your help though, cheers.

delta
26-07-09, 11:07 AM
the disable bit only disables the trigger at the OTHER SIDE. the trigger at the side it arrives at is enabled when it arrives there.

IQ1000
26-07-09, 10:20 PM
wow, what is it with everyone wanting to do really really complex things in their games?! :p


Sorry Delta... Did not mean to make you angry... :cry:

I tried and tried and tried to create my own custom functions, but they were all failures. After trying as much as my mind could muster, I finally decided to give in a post it.
Thanks for the quick reply though! :v2_dizzy_happy: I'm trying to incorporate this into my game now. Hopefully it will work. This will really help out for my day and night themes!!! :D

xelanoimis
27-07-09, 10:43 AM
To IQ1000:

Your initial code makes sense in a "latent" function. That is a function that can be "interrupted". Like a Message or an Action event. This way the WaitTime will work as expected. You can't use this directly in the room's update function, which is not latent.
For that see Jamie's suggestion.

Another option to what Jamie's suggested is to declare the timer as a "player property" instead of a game's global property. And somewere on the update handler to... update it and set player's colors.

macon
27-07-09, 12:33 PM
I did this in 'Yolfolk to the Rescue' where when you found a piece of combination if would flash for about 3 seconds. The same principle can be applied to changing Dizzy's colour for a short period whilst play still continues.
I did it the way Alex suggests above.

1. When you switch colours for the player. Set the players P_STATUS property to 60. (This counts how many game loops will pass before the players colour changes back. For a longer delay increase it, for a shorter one decrease it).

2. In the Game Update if the players status is greater then zero (Dizzy has changed colours) decrease 1 from the player status. When the player status reaches zero switch back the players colour.

A note on using P_STATUS or O_STATUS :

I've noticed alot of examples in this forum are using a player or objects status property. On my first game 'Excalibur Dizzy' I found strange things were happening. I tracked down the problem and there was a particular object whose status property was being used for three different things and sometimes this could conflict.

Fortunately there are extra properties that you can use in a similar way to the status property. These are O_USER, O_USER +1, O_USER + 2 etc or P_USER, P_USER + 1 etc for the player. If you are using the players status for anything else and there is a chance of conflict then I would use a user property. Don't make my mistake.

delta
06-08-09, 08:43 PM
i generally tend not to use custom Player properties in my games now (i've made that mistake before...!), as i find that Game properties are a lot more suitable. If i use custom Object properties, i'll define them in gamedef.gs (usually from about number 35 or 40 onwards) and call them by name, rather than number. This solves the possibility of them conflicting.

delta
21-08-09, 07:14 PM
oh ALEX!!!! :p

i've found a problem with DizzyAGE v2.3 :(

it's this: ObjPresentCount( ) no longer counts all objects in the present room, but also in all 8 rooms surrounding the current room too!

This is a problem if you want to move all the objects in the current room (but not in surrounding rooms).

I've used a workaround for where i was having the problem, but it may be an issue for others, or indeed for other games that have already been updated to v2.3!

and yes quiggie, this is the cause of the problem you were having! :p

quiggie
21-08-09, 08:16 PM
how did you know i'd have a nosey on here???????? :v2_dizzy_tongue2:

Lord Dizzy of Yolkfolk
23-08-09, 08:50 AM
For Under waterplay using bubbles (waterplay set to 1)

In gamedef.gs ive set the number of bubbles & the 1st ID number for the first bubble. The other being consecutive as it says.

The default being:-
#def ID_BUBBLES -1 // set this to the first valid bubble object. the rest of the PLAYER_BUBBLES bubbles have consecutive ids. used in WaterPlay

Now the game runs ok & it works but for some reason you get an error if you try to restart the game though. If I change the ID back to -1 then it doesnt happen :v2_dizzy_confused2:

Is there something I havent done ?

Additionally:-
How do you get under water creatures to face the other way between waypoints, when coming back the other direction.

Can you speed up the running out of air, dizzy seems to beable to get a long way without needing, also when hes running out if you hit left or right he seems to not run out, is this because he using the bubbles ?

delta
23-08-09, 10:46 AM
hmmm i've never had an error relating to the bubbles when you restart the game. that's rather odd.

for flipping baddies, set User Property 33 to '1' in one of the waypoints (it works like object property 'flip'). experiment with which waypoint you need to use it in, and you can also experiment with different numbers (2,3,4 etc) to get them facing different ways

regarding the air level, you can either change AIR_LEVEL in def.gs to a lower number to give him a lower initial level of air, or if you just want it to reduce quicker, change the 'airlevel-1' to a greater number in the following line of code in function PlayerUpdateWaterPlay() in Player.gs:



if( airlevel>0 ) { PlayerSet(P_AIRLEVEL,airlevel-1); }

Lord Dizzy of Yolkfolk
23-08-09, 05:05 PM
hmmm i've never had an error relating to the bubbles when you restart the game. that's rather odd.

Yes this is most peculiar & I cant seem to rectify it, game works fine as long
as you dont want to restart from menu. If I put back to -1 then its no problem
but then I cant use bubbles for effect.

Note:- Ive done the bubbles as items but obviously not where can be picked up, is this correct ?

Error I get is:-

http://i654.photobucket.com/albums/uu269/Lmtthw/ErrorMessage.jpg

Any ideas ?


for flipping baddies, set User Property 33 to '1' in one of the waypoints (it works like object property 'flip'). experiment with which waypoint you need to use it in, and you can also experiment with different numbers (2,3,4 etc) to get them facing different ways

regarding the air level, you can either change AIR_LEVEL in def.gs to a lower number to give him a lower initial level of air, or if you just want it to reduce quicker, change the 'airlevel-1' to a greater number in the following line of code in function PlayerUpdateWaterPlay() in Player.gs:
if( airlevel>0 ) { PlayerSet(P_AIRLEVEL,airlevel-1); }


Thanks. Got this working much better. Dont have to use baddie tiles with symmetry now lol

Meph
23-08-09, 05:11 PM
Hey remember this is what i was having problem with when coding MRD.. it took bloody ages to track down and fix... if i get time I'll run though the forum and see if i can't find the posts.. the script can't divide by Zero or something..!!!!!
i also got the error when you lost all lives and had to restart.

I remember having to replace every bit of code to try and track it down with an untouched script folders.. lol Real nasty bug it was.

delta
23-08-09, 05:18 PM
hmmm yes it's definately a divide by 0 problem. IF i remember rightly, you have to have the status for the bubbles set to 1. I could be wrong, but it wouldn't harm to try it.

Meph
23-08-09, 05:26 PM
yes bubbles need to be disabled.. i just check the MRD progress topic when i Had the problem.

Lord Dizzy of Yolkfolk
23-08-09, 05:35 PM
Hey remember this is what i was having problem with when coding MRD.. it took bloody ages to track down and fix... if i get time I'll run though the forum and see if i can't find the posts.. the script can't divide by Zero or something..!!!!!
i also got the error when you lost all lives and had to restart.

I remember having to replace every bit of code to try and track it down with an untouched script folders.. lol Real nasty bug it was.

I vaguely recall yes you was doing something with bubbles, if you can that be good. Ive set the bubbles to status 1 but unfortunately thats not rectified it.

What I find strange is the game works when you load but not if you restart within the menu.....and what exactly is being divided by 0 as youve changed the Id from -1 to ID number of the bubble. Put back to -1 and it doesnt happen.

delta
23-08-09, 05:39 PM
yes bubbles need to be disabled.. i just check the MRD progress topic when i Had the problem.

ahh yes, that's right.

Lord Dizzy of Yolkfolk
23-08-09, 05:39 PM
yes bubbles need to be disabled.. i just check the MRD progress topic when i Had the problem.

Ahh well done Meph !! Cheers. Think that has done the trick & resolved it :v2_dizzy_thumbsup:

Can ignore above now lol


All working fine and dandy now the water section I done thus far.

Meph
23-08-09, 05:55 PM
:dizzy_cool:
fantastic

delta
30-08-09, 09:22 AM
why oh why doesn't this work:



test4 = strsub((str "%02i")PlayerGet(P_HOUR),0,1);
GameSet(G_OHOUR2,test4);


it's basically the second line it's failing on. it doesn't seem to like me trying to assign 'test4' to a Game variable. i've even tried setting it as a string:



test4 = strsub((str "%02i")PlayerGet(P_HOUR),0,1);
GameSet(G_OHOUR2,(str)test4);


trying to set it to a player variable doesn't work either. same error.

:( any ideas?


EDIT:: it's ok, i've defined it as a non-string global variable, which seems to work fine for what i need.

xelanoimis
30-08-09, 01:48 PM
Game variables are integers. And so are the player's and objects' properties.

You can cast the test4 string to an integer if you really want, but I think there's a faster way to do what you need, working only with integer numbers.

delta
30-08-09, 01:58 PM
yeah it seems that splitting the two digits in the 'hour' player variable somehow stops them from being an integer. ah well.

also, i don't know if you saw this alex:


i've found a problem with DizzyAGE v2.3 :(

it's this: ObjPresentCount( ) no longer counts all objects in the present room, but also in all 8 rooms surrounding the current room too!

This is a problem if you want to move all the objects in the current room (but not in surrounding rooms).

I've used a workaround for where i was having the problem, but it may be an issue for others, or indeed for other games that have already been updated to v2.3!

Lord Dizzy of Yolkfolk
30-08-09, 07:18 PM
When being killed by a baddie how do you get dizzy to respawn to a safe position to avoid losing all lives by being respawned in same danger position ?

delta
30-08-09, 08:10 PM
first allocate a 'death' number to it, to identify the death type in the code.

then it's simply:



func PlayerRespawn_NUMBER()
{

...

}


and whatever positioning or other stuff you may want to do in the middle. Be aware that you will have to replicate all the stuff that respawning does in the first place (see player.gs for what it actually does)

so you'll probably end up with something like this:



func PlayerRespawn_NUMBER()
{
SamplePlay(FX_RESPAWN);
PlayerSet(P_DEATH, 0);
PlayerSet(P_LIFE,1);

PlayerSet(P_X,400);
PlayerSet(P_Y,200);
PlayerEnterIdle();
MusicFade(0,3);
MusicRestore();
}


that's very slightly altered code from IID.

Lord Dizzy of Yolkfolk
30-08-09, 10:26 PM
Thanks, got it working fine from your explanatory help :v2_dizzy_happy:

xelanoimis
31-08-09, 05:36 PM
About the ObjPresentCount:

It returns the objects in all 9 rooms (current room+8 surrounding) only in G_VIEWPORTMODE, because for scrolling games all these can be visible from the current room. In normal mode it works as before (or so it should) returning objects only from current room, with a small "safety" border (16 pixels on each side).

For scrolling games, if you must know the objects in the vicinity of the player, test all "present" objects if they are in a specific range on both x and y coordinates.

delta
31-08-09, 05:41 PM
ah yes i see. :)

yeah that's what i did, used x and y co-ordinates to narrow it down to the one room.

Meph
03-10-09, 12:09 PM
How do you get those objects or whatever the flash?
Back in doing MRD i wanted the letters too flash but failed in working it out, looking at the few games that included it i couldn't work out what i should be looking for or where... l

While im not building a game now i will do soon and just getting prepared.. i hope to include some flashy things.

macon
03-10-09, 01:43 PM
For the flashing combination objects in 'Yolkfolk to the Rescue' I used animated tiles. Turning the flash on or off can then be controlled by setting or unsetting O_ANIM.

The same effect could also be done by scripting to cycle through different brush colours. But my approach is script free which is why I did it.

Below is the tile for the flashing 'N'

http://i456.photobucket.com/albums/qq282/masonandy/4052n16.jpg

delta
14-10-09, 05:15 PM
Alex, I'm trying to change O_MAP from an UpdateRoom function, but it's simply not working.

This is a cut down section of the code i'm using:



func UpdateRoom_6_1()
{
screen = ObjFind(2011);

sw = ObjGet(screen,O_W);
sx = ObjGet(screen,O_X);
sm = ObjGet(screen,O_MAP);

if(ObjGet(screen,O_STATUS)==2)
{
sm=sm+1;
sx=sx+1;
sw=sw-1;
if(sw<=0)
{
sw=0;
ObjSet(screen,O_STATUS,0);
}
ObjSet(screen,O_MAP,sm);
ObjSet(screen,O_W,sw);
ObjSet(screen,O_X,sx);
ObjPresent(screen);
}
}


as far as i can see it should work perfectly. In fact it does, because i used a println to see what the value of 'sm' is, and it changes just as it should. What it doesn't do however, is show those changes in the game. :v2_dizzy_confused2:

What (if anything) am I doing wrong?

Bazi
15-10-09, 12:10 PM
Hi delta !

I've tried your code and it works perfectly. The brush 2011 (Theo brush in my case) is hiding from left to right (when O_STATUS = 2). Maybe something with the properties of the brush 2011 in the map ?

delta
15-10-09, 12:13 PM
thanks for that Bazi, i'll do more checks later.

delta
15-10-09, 07:24 PM
right. The issue is because i'm effectively 'cloning' the item. That is, copying the properties from item A (tile, colour, all 4 map coordinates, etc), and placing those properties onto item B, effectively making it exactly the same. The code that is shown above is then executed on item B.

I've tried the above code on item A instead, and it works fine, but i need it to work on item B, and it just doesn't. even though with copying all the properties, item B should be exactly the same as item A. :v2_dizzy_confused2:

xelanoimis
16-10-09, 08:52 PM
Not sure what your case is. The code looks OK. The mapping should show as it's values change. And there's no need to Present it when changing the mapping. Maybe item A is overlapping item B. Maybe the mapping of item B is overwritten again from item A, after changed. I assume both items are dynamic (objects) from the beginning.

delta
16-10-09, 10:59 PM
ok, this is the code in it's entirety. To call it, use: Change_Screen(ITEM_ID,OBJECT_TO_BE_COPIED,"NEW_ITEM_NAME");

ITEM_ID is the id number of the item used from inventory
OBJECT_TO_BE_COPIED must be 16x16 pixels (the size of an item), dynamic, etc etc.



func Change_Screen(present,obj,newname)
{
present = ObjFind(present);
obj = ObjFind(obj);
screen = ObjFind(2011);
beam = ObjFind(2040);

DoDropObject(present);
ObjSet(present,O_X,1552);
ObjSet(present,O_Y,224);
ObjPresent(present);

PlayerEnterIdle();
PlayerSetPos(1540,238);
PlayerEnterScripted();

WaitFrames(8);

ObjSet(beam,O_X,1552);
ObjSet(beam,O_Y,224);
ObjSet(beam,O_DISABLE,0);
ObjPresent(beam);

ObjSet(screen,O_TILE,ObjGet(obj,O_TILE));
ObjSet(screen,O_COLOR,ObjGet(obj,O_COLOR));
ObjSet(screen,O_MAP,ObjGet(obj,O_MAP));
ObjSet(screen,O_MAP+1,ObjGet(obj,O_MAP+1));
ObjSet(screen,O_MAP+2,ObjGet(obj,O_MAP+2));
ObjSet(screen,O_MAP+3,ObjGet(obj,O_MAP+3));

ObjSet(screen,O_X,1584);
ObjSet(screen,O_Y,224);
ObjSet(screen,O_W,1);
ObjSet(screen,O_DISABLE,0);
ObjSet(screen,O_STATUS,1);

ObjSetName(present,newname);
ObjSet(present,O_STATUS,1);
}

func UpdateRoom_6_1()
{
screen = ObjFind(2011);
if(!IsUpdate(ObjGet(screen,O_DELAY))) return;

beam = ObjFind(2040);

sw = ObjGet(screen,O_W);
sx = ObjGet(screen,O_X);
sm = ObjGet(screen,O_MAP);

x = ObjGet(beam,O_X);

if(ObjGet(screen,O_STATUS)==2)
{
ObjSet(beam,O_DISABLE,1);
sm=sm+1;
sx=sx+1;
sw=sw-1;
if(sw<=0)
{
sw=0;
ObjSet(screen,O_STATUS,0);
PlayerEnterIdle();
}
ObjSet(screen,O_MAP,sm);
ObjSet(screen,O_W,sw);
ObjSet(screen,O_X,sx);
ObjPresent(screen);
}
if(ObjGet(screen,O_STATUS)==1)
{
sw=sw+1;
x=x+1;
if(sw>=16)
{
sw=16;
x=1567;
ObjSet(screen,O_STATUS,2);
}
ObjSet(beam,O_X,x);
ObjPresent(beam);

ObjSet(screen,O_W,sw);
ObjPresent(screen);
}
}


if you're still not sure what the problem is Alex, i can email a copy of the game over to you for you to have a look at. It's completely finished, apart from this little annoyance. I can use a work-around to get it to do what i want, but i don't want to, i want to find out why this code isn't doing what it should do.

Lord Dizzy of Yolkfolk
18-10-09, 04:11 PM
Not sure how best to describe this but hopefully will be understood but does anyone know how to code or what you need to do to show completion of game celebration at the end. Some of the official game(s) had it where looks like fireworks going off.

This feature will fit in perfectly with the theme for my next game (yes the good news is im slowly working on another when the mood takes me).

Lex_Hedley
18-10-09, 04:31 PM
I've found
http://www.yolkfolk.com/bb/showthread.php?t=116

but i think you can just do a similar thing to the start screen
http://www.yolkfolk.com/bb/showthread.php?t=385

maybe of some use

http://www.yolkfolk.com/dizzyage/books/dizzyage/page17_cutscenes.html

Lord Dizzy of Yolkfolk
18-10-09, 05:25 PM
Thanks Lex Hedley, all good stuff. I know a little of how to end a game with doing so for Swampland. Im after specifically the end bit of a game that shows how to do the like firework celebration, not sure how best to describe it. That cutscene information looks useful though, dunno if whether I will be that adventourous though lol.

Lord Dizzy of Yolkfolk
23-10-09, 03:55 PM
Following the link Lex Hedley game me ive been attempting to put an opening cutscene into my next game, yes I getting a bit adventourous lol.

Now its works fine except I cant get the character to disappear after dialogue. Here is code if anyone can find where the problem lies.





func OpenRoom_22_6()
{
ScrRequest(gs_fid("PlayCutscene"));
}

func PlayCutscene()
{
// position player and avoid eventual jump entries
PlayerSetPos(5404,934);
PlayerEnterIdle();

// enter talk
PlayerWalkTo(6060);
PlayerEnterIdle();
idx = ObjFind(2061);
if(ObjGet(idx,O_STATUS)==0)
Message1(3,4,"Message From Character");MessagePop();
Message2(7,4,"Message Frim Dizzy");



MessagePop();




// walk closer
PlayerWalkTo(6164);
PlayerEnterIdle();
Message1(3,4,"Message From Character");
Message2(12,6,"Message From Dizzy");


MessagePop();


idx = BrushFind(2061);
BrushSet(idx,B_DRAW,0);


}

// make the player walk to posx coordinate
// posx must be reachable (multiple of 4 pixels)
func PlayerWalkTo( posx )
{
while(true)
{
ClearKeys();
x = PlayerGet(P_x);
if(x<posx)
SetKey(KEY_RIGHT,1);
else
if(x>posx)
SetKey(KEY_LEFT,1);
else
return;
stop;




}

if(ObjGet(idx,O_STATUS)==1)
{



}
}


Character is brush ID 2061 and even though im using idx = BrushFind(2061); BrushSet(idx,B_DRAW,0); where ive been trying it in several places within the code I cant get the character to disappear.

Ive even taken it out of the code and used a hidden collider to set idx = BrushFind(2061); BrushSet(idx,B_DRAW,0); but thats causes an error, if you click no on the error message then character disappears and you can continue.

Also I would appreciate if anyone can help on my previous enquiry as was no respond on that. Thanks.

macon
23-10-09, 05:47 PM
After BrushSet(idx,B_DRAW,0), put
GameCommand(CMD_REFRESH);
This will redraw the brushes.

However it is much easier to do this

idx = ObjFind(2061);
ObjSet(idx,O_DISABLE,1);

Then there is no need to redraw the materials map.
Oh! and make sure it is a dynamic brush.

Lord Dizzy of Yolkfolk
23-10-09, 06:30 PM
idx = ObjFind(2061);
ObjSet(idx,O_DISABLE,1);

Thanks Macon, I had tried that earlier but wasnt working, anyway went back to it and played about with the sequence of the code and managed to get it working now, cheers :v2_dizzy_happy:

xelanoimis
28-10-09, 09:10 PM
Jamie,
I can't spot any issues in the code you posted, but I don't get the big picture either.

Please email the game to me along with a save game (if needed) and instructions about what to do and what should work but it doesn't (include relevant objects ids if I must check any).

Alex

Lord Dizzy of Yolkfolk
06-12-09, 06:25 PM
Anyone explain how to get round this or what may be causing it.

Dizzy when exiting a room (a door) to reposition outside sometimes for no apparent reason he dies. Most of time you can action and he appears no problem but it seems to happen randomly...:v2_dizzy_confused2:

I cant see why it should be happening.
Code below:-

//////////////////////////
//EXITING THE .....
//////////////////////////


func ActionObject_2165()
{
idx = ObjFind(2165);
if(ObjGet(idx,O_STATUS)==0)
{
Message0(5,5, "EXITING THE\n....");




PlayerSetPos(6412,1032);


MessagePop();

idx = ObjFind(2165);



}
if(ObjGet(idx,O_STATUS)==1)
{
idx = OpenDialogInventory();
if(idx!=-1) UseObject(idx);
}
}

delta
06-12-09, 06:49 PM
hmmm not sure tbh. I would recommend moving the messagepop to before the playersetpos, but i suspect that there is some other bit of coding that is being activated by accident,

is he dying before re-position, after? when?

you could also put a println line in in the death sequence in player.gs, that grabs the 'death' property and outputs it into dizzy.ini, something like this:



func PlayerLoseLife()
{
credit = PlayerGet(P_CREDITS)-1;
PlayerSet(P_CREDITS, credit);

death = PlayerGet(P_DEATH);
println(death);
msg = PlayerDeathMessage(death);


assuming you use death properties on stuff that kills him, that would help to narrow it down, and point you in the right direction.

Lord Dizzy of Yolkfolk
06-12-09, 07:17 PM
He dies when he reappears but its random, well at the moment its on average 1 in 3-4 occasions it happens.

Yes I use death properties but its the default one that comes up.

Anyway thanks for responding.

delta
06-12-09, 07:21 PM
odd. there must be something there that is conflicting. something on room exit, or room entry. also, is there anything nearby that is deadly?

Lord Dizzy of Yolkfolk
06-12-09, 07:35 PM
There isnt anything nearby that is deadly, ive tried checking all brushes around in case ive accidentally picked up any properties from other brushes. Ive had this before and managed to get round it by changing the x, y positions on reposition but this one no matter what I put it to he still dies. Ive tried changing the ID numbers too in case ive accidentally reused one.

Like you say something is probably conflicting.

I might have to move all brushes off the room and just have the triggers and see what happens.

xelanoimis
06-12-09, 07:54 PM
Use println messages in relevant positions of the script (handlers.gs, PlayerHurt), to track what kills Dizzy, to find who gets his energy.
Use [`] (tilda key) to open the console and view the log at runtime.

Lord Dizzy of Yolkfolk
06-12-09, 08:17 PM
Thanks for trying to help although im not technical enough to know what im doing as regards what you and Jamie have suggested, it is peculiar though.

delta
06-12-09, 08:35 PM
send me a beta version with a save game just before it happens and i'll have a look at it :)

macon
06-12-09, 08:57 PM
Is Dizzy being re-positioned right at the edge of a screen because if he is then he could be touching a deadly brush on an adjacent screen. Just because it is not on the current screen doesn't mean it can't kill you.

If you turn on scrolling you can see if anything on a neighbouring screen is causing Dizzy to die.

Lord Dizzy of Yolkfolk
06-12-09, 09:30 PM
send me a beta version with a save game just before it happens and i'll have a look at it :)

Thanks for offering Jamie, if its ok if I can't resolve it by time it's nearing completion then I will, so bear in mind for later if you can.

Either yourself or Alex can before I do a release anyway but thats sometime off.

Its like a random magic door whether you get out alive or not lol...Fortunately its not a critical door as you wont need to go in
much.

EDITS Seems I have resolved this problem now, not sure how I did but it doesn't appear to be happening now : )



From Macon:-
Is Dizzy being re-positioned right at the edge of a screen because if he is then he could be touching a deadly brush on an adjacent screen. Just because it is not on the current screen doesn't mean it can't kill you.

If you turn on scrolling you can see if anything on a neighbouring screen is causing Dizzy to die.

No he reappears in the middle of the room.

delta
08-01-10, 10:04 PM
Ok, this one has me beat (well, i've not tried too hard, but i'm up against a brick wall with it). Basically what i'm trying to do is display text on the loading screen using HudDrawText.

I've put the relevant code into the loading screen part of HandlerDrawHUD, and have loaded the fonts before the loading screen in start.gs, but it's coming up with the error:

GS_ERROR: BADTYPE, fn=HudDrawText, line=-1, file="unknown"
GS_DESC: 1, 0, ""
CALLSTACK: HudDrawText:-1 < HandlerDrawHud:447 < .

line 447 is the first line it tries to call HudDrawText on. Looking at the error, am i right in thinking that it's trying to find a file called 'HudDrawText'? If so, why? :v2_dizzy_confused2: It's puzzling me.

Colin
08-01-10, 10:24 PM
could it have something to do with dialogs.gs not loading early?

delta
08-01-10, 10:44 PM
could it have something to do with dialogs.gs not loading early?

I thought about that, so I moved the loading of start.gs so that it is the last file to load, but it still doesn't work.

Colin
08-01-10, 10:49 PM
but doesn't it need to be one of the 1st. HandlerDrawHud needs it.

macon
09-01-10, 12:07 AM
I've been there with this problem.

Putting my code at the start of 'HandlerGameStart()' worked for me. This is the function that calls start.gs.

delta
09-01-10, 11:12 AM
ok, i fixed that problem (i hadn't declared fontid!), but it's still not displaying the text. I've used println to determine that it does actually know what the text is, it's just not displaying it. :(

xelanoimis
09-01-10, 11:45 AM
Here it goes:

The first error was because a variable used in HudDrawText was not found. Expected integer (1) and found NIL (0). Probably the fontid.

Then you must set the font, shader and color before drawing.



fontid = FONT_DEFAULT;
HudFont( fontid );
HudShader( 0 );
HudColor( 0xffffffff );
HudDrawText( fontid, 16,4,8,8, "TA TA!!!", 0 );


If you fixed that, you don't see the text because the font and it's tile is not loaded at that time. Check the start.gs for the flow. You'll see that only the tiles from the "loading" folder are loaded and then unloaded.

I tested by loading the font and the tiles from menu there and it worked fine.



// TILES
FontLoad("data\\fonts");
TileLoad("data\\tiles\\loading\\");
TileLoad("data\\tiles\\menu\\");
stop; // wait for one draw, to paint the loading screen
TileUnload(); // avoid find the loading as duplicate
TileLoad("data\\tiles\\");
if(TileCount()==0)
{
gs_messagebox("No tiles loaded!","ERROR");
GameCommand(CMD_EXIT);
stop;
}

// SOUNDS
MusicLoad( "data\\music" );
SampleLoad( "data\\samples" );
....


Alex

delta
09-01-10, 12:04 PM
yeah i do load the tiles and font as pretty much the first thing:


if(!GameGet(G_RESTART))
{
time = gs_time();

// TILES
TileLoad("data\\tiles\\loading\\");
stop; // wait for one draw, to paint the loading screen
TileUnload(); // avoid find the loading as duplicate
TileLoad("data\\tiles\\");
if(TileCount()==0)
{
gs_messagebox("No tiles loaded!","ERROR");
GameCommand(CMD_EXIT);
stop;
}

// FONTS
FontLoad("data\\fonts");

// SPEECH
GameSet(G_SCROLL,10035); // set scroll dialog bar
GameSet(G_DIALOG,10035); // set dialog to text
stop; // wait for one draw
SampleLoad( "data\\samples" );

GameSet(G_SCROLL,10036); // set scroll dialog bar
GameSet(G_DIALOG,10036); // set dialog to text
SampleLoad( "data\\samples2" );

GameSet(G_NEWLOAD,1);
stop; // wait for one draw, to paint the second loading screen

GameSet(G_SCROLL,10037); // set scroll dialog bar
GameSet(G_DIALOG,10037); // set dialog to text
stop; // wait for one draw
SampleLoad( "data\\samples3" );

GameSet(G_SCROLL,10038); // set scroll dialog bar
GameSet(G_DIALOG,10038); // set dialog to text
stop; // wait for one draw
SampleLoad( "data\\samples4" );

MusicLoad( "data\\music" );

// if loading was too fast, wait a few seconds to see the loading screen page
if(gs_time()-time<LOADINGTIME*1000) WaitTime(LOADINGTIME);
}

xelanoimis
09-01-10, 12:24 PM
It's before the "stop" instruction where you must load both font and font tile. See how my example is different from the code you posted.

I tested it on the default template and it did display the text. If you need the full script, I can provide it.

Consider that the loading screen is painted only once and not refreshed during loading. If you move another window over it it will not be repainted. So progress bars or other animated things are not supported.

delta
09-01-10, 12:39 PM
Consider that the loading screen is painted only once and not refreshed during loading. If you move another window over it it will not be repainted. So progress bars or other animated things are not supported.

in CoTM i have two loading screens, set using a game variable, so it does change (as in TLoD). therefore if i can change the loading screen in the HUD handler, shouldn't i also be able to change what text is displayed too?

xelanoimis
09-01-10, 02:03 PM
Yeah, basically if everything needed is loaded (font and font tile) and you can display (change) an image you should be able to display (change) text too.

It might be something else. Try to display the font tile as an image there to see if it's available. I don't know if you keep it in the tiles/menu folder, but I don't see your code loading tiles from there with TileLoad.

As I said, you need both the FontLoad for the .fnt file and the TilesLoad for the font's tile.

delta
09-01-10, 02:23 PM
it loads all the tiles with TileLoad("data\\tiles\\"); near the start of the file

delta
09-01-10, 02:25 PM
It might be something else. Try to display the font tile as an image there to see if it's available.

I just tried that and it displayed it fine. I'll send you a link to download the next build of the game so you can have a look at it

xelanoimis
09-01-10, 03:32 PM
Oh, yeah. didn't see that :)
Send me the build and I see what really happens.

Meph
18-01-10, 02:50 PM
The train ID (spiders) we can do vertically.. can we do them horizontally?

Meph
08-02-10, 08:50 PM
I'm trying to doa few thing with the custom movements however everything works fine other then the movement.. lol Dizzy just stands still, im pretty sure its got to be something very simple im missing but for the past 3 hours I've had no luck. :dizzy_frown:

delta
08-02-10, 09:07 PM
depends what you're wanting to do, you haven't given much detail! Plus initially, the movement.gs file is very complex

first things first, have you enabled the custom movement, so that the game actually uses the movement.gs file?

Meph
08-02-10, 09:42 PM
Im not sure, prehapes thats why it's not working.

xelanoimis
09-02-10, 06:14 PM
Check the "Shrink Demo" too.

Meph
09-02-10, 10:04 PM
^ I've been looking at that, Dizzy shrinks but wont move.
Maybe I'll have another crack at it tomorrow.

xelanoimis
10-02-10, 09:09 AM
You can compare the files of the default template and those of a demo, to see all the changes the demo did. Maybe you missed one of them, essential for moving.

For easy comparing files and folders I use Total Commander.

Meph
10-02-10, 03:10 PM
:tup: Did it... took less than 5 minutes.
Not sure why i couldn't get it to work, i have a feeling it wasn't finding the custom movement folder, perhaps i made a typo or something.

Huckleberry
18-02-10, 05:13 PM
Could anyone tell me how I can change the PTILE_WALK to another tile when I action something? I'm sure I'm being dense about this as my cold has turned me into a buffoon.

I'm doing this puzzle in such a roundabout way but if I get the tile to change it should work well enough.

delta
18-02-10, 05:22 PM
i'll post something either later tonight or tomorrow about this. It all depends how complicated you want it really. Whether you just want something similar to the glasses in IID, or just the walking tile and no others. Also, would it be permanent, or just a temporary effect?

Huckleberry
18-02-10, 05:33 PM
Cool, thanks a lot!

I'd only need the walk one I reckon as that's all it's doing. It'd be temporary. Every time you action something it would change the tile then hopefully change back when you hit a collider. Is that possible?

I think you're the opposite of me; you know what things actually do and I just Delboy my way through it! haha.

Huckleberry
27-02-10, 01:35 PM
I worked out how to do it. It was P_TILEWALK not PTILE_WALK. What a numpty. Sorry for wasting your time!

Onwards!

Huckleberry
01-03-10, 01:35 PM
Okay, I forgot that I'd also have to change a tile to show Dizzy was wearing his Scuba gear so now could anyone tell me what the if statement would be if the P_COSTUME was in effect. Thankyou :)


func Change_Blah()
{
if
{
Blah = PlayerGet(P_TILEIDLE)+PlayerGet(P_TILEWALK);
PlayerSet(P_TILEIDLE,8011);
PlayerSet(P_TILEWALK,8011);
}
else
{
Blah = PlayerGet(P_TILEIDLE)+PlayerGet(P_TILEWALK);
PlayerSet(P_TILEIDLE,8010);
PlayerSet(P_TILEWALK,8010);
}
}

delta
01-03-10, 01:41 PM
func Change_Blah()
{
if(InventoryHasItem(ID_SCUBA))
{
Blah = PlayerGet(P_TILEIDLE)+PlayerGet(P_TILEWALK);
PlayerSet(P_TILEIDLE,8011);
PlayerSet(P_TILEWALK,8011);
}
else
{
Blah = PlayerGet(P_TILEIDLE)+PlayerGet(P_TILEWALK);
PlayerSet(P_TILEIDLE,8010);
PlayerSet(P_TILEWALK,8010);
}
}


that *should* work...

Huckleberry
01-03-10, 02:41 PM
Just tried it and dizzy disappears. Would you think that it has something to do with costume trying to layer over the original player tile ID? Is that how it works?

P.S. thanks!

delta
01-03-10, 05:11 PM
Just tried it and dizzy disappears. Would you think that it has something to do with costume trying to layer over the original player tile ID? Is that how it works?

P.S. thanks!

no, it 'jumps' the tile numbers to a new number, so that it calls different tiles. It doesn't overlay them, you have to draw them.

Huckleberry
01-03-10, 07:48 PM
Oh right. I wonder why the costume causing the player tile to disappear then; bit strange. Ah well, People will just have to assume that Dizzy takes off his scuba gear for safety reasons. :confused: Got too much other stuff to worry about!

Cheers.

delta
01-03-10, 07:57 PM
sorry, i was doing other stuff earlier while trying to reply. it's disappearing because you don't have a tile for it to display.

ok, let's take the dizzy idle tile as an example. it's tile number 10. the scuba tile is number 40, which is a gap of 30. Look, and you'll notice that the gap between the normal tile and the scuba tile is always 30, for all the tiles. so therefore if you have a new tile in the game, set to, for example, 24, then the scuba version of that tile needs to be number 54, because that's the one that it will look for.

:)

delta
01-03-10, 08:04 PM
actually, scrap that. I forgot you were using your own IDs and code. If you have tile IDs 8011 and 8010, then it should work, however I think why it's not is that you are conflicting with the native dizzyAGE code, which is trying to advance the ID by 30. therefore you're setting it to 8011, and it's then moving it to 8041 (or something like that.)

I wouldn't bet on it, but i'd hazard a guess that something like that is happening.

Huckleberry
01-03-10, 08:11 PM
Flippin' 'eck! Just a re-numbering of a tile and it's all sorted! Yay, thankyou!

Give yourself an actual pat on the back for that, Jamie. I'll know if you don't. You can be first in my 'thanks' list now and we all know how prestigious that is.

delta
01-03-10, 08:42 PM
taking that further, It's then reasonably easy to virtually duplicate the 'scuba' code, and advance it by, say, 300, to do something else (for example, wearing goggles in IID), although you do then have to code it so that it'll switch to scuba in the water if you're carrying both the goggles and the scuba.

the following is the relevant code in HandlerPlayerUpdate() for IID. The top third is for normal dizzy, the middle bit is if the goggles are being worn, and the bottom bit is if the player is playing the arcade games (small dizzy):



// Custom movement test
if(GameGet(G_ARCADE)==0&&GameGet(G_GOGGLES)!=1)
{
// Player set costume
costume = 0;
if(ID_SCUBA!=-1&&InventoryFind(ObjFind(1001))!=-1&&PlayerGet(P_MATCENTER)==MAT_WATER)
{
costume = InventoryHasItem(ID_SCUBA) ? 30 : 0;
PlayerSet(P_COSTUME,costume);
}
else
{
PlayerSet(P_COSTUME,0);
PlayerSet(P_COLOR,0xffffffff);
PlayerSet(P_W,CM_BOXW);
PlayerSet(P_H,CM_BOXH);
}
}
if(GameGet(G_ARCADE)==0&&GameGet(G_GOGGLES)==1) //wearing goggles
{
// Player set costume
costume = 0;
if(ID_SCUBA!=-1&&InventoryFind(ObjFind(1001))!=-1&&PlayerGet(P_MATCENTER)==MAT_WATER)
{
costume = InventoryHasItem(ID_SCUBA) ? 30 : 0;
PlayerSet(P_COSTUME,costume);
}
else
{
PlayerSet(P_COLOR,0xffffffff);
PlayerSet(P_COSTUME,300);
PlayerSet(P_W,CM_BOXW);
PlayerSet(P_H,CM_BOXH);
}
}
if(GameGet(G_ARCADE)==1)
{
PlayerSet(P_COLOR,0xffffffff);
PlayerSet(P_COSTUME,50);
PlayerSet(P_EMOTION,0); // not supported
PlayerSet(P_STUNLEVEL,0); // not supported
PlayerSet(P_W,CM2_BOXW);
PlayerSet(P_H,CM2_BOXH);
CM2_Update();
}


ID 1001 is the snorkel.

looking at it again, there seems to be quite a bit of superfluous code in there, most noticably the colours. I think the width and height sets are so that it's correct if exiting the arcade games, however i'm really not sure they're needed either...

Huckleberry
01-03-10, 08:45 PM
actually, scrap that. I forgot you were using your own IDs and code. If you have tile IDs 8011 and 8010, then it should work, however I think why it's not is that you are conflicting with the native dizzyAGE code, which is trying to advance the ID by 30. therefore you're setting it to 8011, and it's then moving it to 8041 (or something like that.)

I wouldn't bet on it, but i'd hazard a guess that something like that is happening.

Yeah I thought that would happen so I just renumbered the thing+scuba tile by adding 30 and scrapped the first part of the code involving the 8011 part. I'm learning. I'm learning slowly but I am learning! Watch your back for the 2020 competition.

delta
01-03-10, 08:48 PM
Watch your back for the 2020 competition.

haha I have no plans to enter the 2020 comp!

I wouldn't worry anyway. The coding could be the biggest botch job the world has ever seen, but if it works, players won't notice at all. Finding an easier way to code things is a pleasure not shared with the players!

Huckleberry
01-03-10, 08:51 PM
You could do a tenth anniversary of CotM against Grogg Island: Ten Years After.

And they'd both be in 3D.

Colin
01-03-10, 09:04 PM
I used a similar method in SBD to switch character tiles
there were also 2 scuba's in the game. one for dizzy and one for daisy



// Player set costume
costume = 0;
if(chr==1)
{
if(ID_SCUBA!=-1) costume = InventoryHasItem(ID_SCUBA) ? 30 : 0;
}
if(chr==2)
{
if(ID_SCUBA2!=-1) costume = InventoryHasItem(ID_SCUBA2) ? 30 : 0;
costume+=300;
}
if(chr==3) costume+=350;
if(chr==4) costume+=400;
if(chr==5) costume+=450;
if(chr==6) costume+=500;
if(chr==7) costume+=550;
PlayerSet(P_COSTUME,costume);

Meph
02-03-10, 06:30 PM
How possible is it to make an object follow Dizzy around?

Huckleberry
02-03-10, 09:31 PM
More things have gone wrong today than have gone right and it's giving me a right old brainache. Here are a few of the things winding me up today.

1. Are you supposed to respawn out of water if you die in it? Because it's not doing that. I set a death number and respawn function but it ignored me. This leads on to my next problem.

2. I set death numbers for all of my baddies. The ones that move (fish,jellyfish etc.) send back the customised messages and respawn where I want them to but the things that harm/kill which don't move (spikes/crabs etc.) won't do either.

3. When I hit a block of kill over a spike pit it sends me to a last safe place but kills me when I respawn. Those are some deadly spikes!

Why is this happening when I'm so close to completion? I'm close to weeping.

delta
02-03-10, 09:41 PM
How possible is it to make an object follow Dizzy around?

in handlergameupdate(), grab the x and y co-ords of dizzy, and set the x and y co-ords of the item to the same (or an offset). simples. :)