Page 2 of 2

Re: Dizzy Scripting Engine

Posted: Wed Aug 28, 2019 7:15 pm
by payty
Hi,

I think this is a great tool. You have done a good job by creating it. I've started using and I have some questions:

1. Can I create an animated sprite that travels between screens? For instance I want to make a boat that Dizzy will use to cross a river. And I am only able to make it travel inside a single screen. If the river is wider than the screen, the boat returns at the end of the screen without going in the nearby one.

2. Can I set the color of a tile inside the DizzyAge map editor? For instance I have a brick that needs to be red in some screen and blue in another. I want to use the same tile and change the color in the map editor. There is a 'color' property there but it seems that it is not working. I think the best way would be to create a white brick and change the color as needed.

3. Can I change dynamically the material of an object, using a script? A little example would be great.
I have used the script below but it seems it is not working.
roomfind(9,2)
SET (E, RET)
objfind(111,E)
objset(RET,O_MATERIAL,2)


Also, for future versions, do you plan to create a feature for dynamic memory allocation? Or at least some function to allow the developer to change memory allocation as needed.

It would be very useful as dizzy is not a game with much sound and this way the developer could allocate some memory that is used for sounds to the graphics and create more rich animations for instance.

For other types of games, maybe sound is more useful and it could allocate more to sound al less to graphics.

Re: Dizzy Scripting Engine

Posted: Sun Sep 01, 2019 8:33 pm
by Hippiman
Hi,
Thanks for your reply.

The engine has limitations compared to DizzyAge. All of them are related to the technical limitations of the ZX-Spectrum: a weak processor,
limited amount of memory, etc.

1)Unfortunately, only Items can travel between screens. All other dynamic objects are always attached to the screen in which they were created.
If you want the boat to travel between screens, then on each screen you need to make your own copies of the boat and manage them using scripts.

2)Now this feature is turned off in the engine. As it turned out as a result of tests, “colored” objects slow down rendering of the screen, and this is critical for a comfortable gameplay. DizzySE has a very large tileset (by ZX-Spectrum the standards of course),it is better to have several copies of one object with different colors and display them quickly on the screen than to save a little place in the tileset and get flicker,
when switching from screen to screen.

3)Of course, just donf forget to use the UPDATE_MAT_OBJECT (pointer to object) function. This function will update material map under the object.
You can use script like that:

objroomfind(111,9,2)
objset(RET,O_MATERIAL,2)
update_mat_object (ret)

P.S.
Material with id=2 (hurt) not used in the engine. It can be used as a material transparent for the player and not transparent for moving objects (for elevators, boats, birds, etc.).

4)Unfortunately this is not possible. The reason is the same speed. A more complex organization of memory will entail
more computing and lower game speeds.

Re: Dizzy Scripting Engine

Posted: Mon Sep 02, 2019 7:09 pm
by payty
it works great!

The reason my scripts were not working is because the objects were set as static. I've changed to dynamic and it's ok now.
I assume that Flip property is also disabled for the same reason -> performance.


By dynamic memory allocation I did not mean really dynamic, without any intervention from the developer. Just some simple mechanim like

set_graphics_memory(23296)
set_sound_memory(1024)
etc
etc

But after all, you know how you have designed the engine and I am sure that you have chosen the best way.

Re: Dizzy Scripting Engine

Posted: Mon Sep 02, 2019 7:47 pm
by Hippiman
By dynamic memory allocation I did not mean really dynamic, without any intervention from the developer. Just some simple mechanim like

set_graphics_memory(23296)
set_sound_memory(1024)
etc
etc
Will not work. The memory of the zx spectrum is splited by 16kb pages.
23296 for graphics - it is one full page and another 6912 somewhere. And if these 6912 are not where in one piece?
To automatically allocate objects across pieces of memory, I need something like artificial intelligence. :) And there is no place for the new code, but I want to add a system timer.

Re: Dizzy Scripting Engine

Posted: Tue Sep 03, 2019 10:26 am
by payty
Ok, got it! It's because of the bank switching.

Re: Dizzy Scripting Engine

Posted: Thu Sep 05, 2019 2:15 pm
by Hippiman
Payty, if you have questions about "how to do something." Ask here and I will answer with pleasure.

Re: Dizzy Scripting Engine

Posted: Sun Sep 08, 2019 5:35 am
by payty
Well, so far I've been experimenting with map creation. Although I do not have any experience with DizzyAge, I find it very easy.

I do have some questions related to sprites.

1. Sprites are animated only in two frames? Can I make 3 or more frame animated sprites?
2. Areas are fixed as defined in the help document? For example in the documentation, first sprite is a 2 frame animation with 3x1 characters each. This leads to a total of 6 characters for this sprite. Can I redefine this area as a sprite of 2x1 plus another one of 1x1 characters? Or the areas are fixed?

3. There are some areas marked with a big X. These cannot be changed at all? they should be left as they are?



And another one related to map definition. I see that there is a 'layer' property on each tile. Can i make an effect of dizzy waking behind objects? Like in the attache picture, where Dizzy is behind that plant.


Thanks a lot for willing to help. Be sure I will have more questions when I will start using the scripting part more :v2_dizzy_biggrin:

Ps. Projects statistics is a very useful tool, it helped me a lot with optimization of memory usage for graphics.

Re: Dizzy Scripting Engine

Posted: Sun Sep 08, 2019 8:55 pm
by Hippiman
Due to the limitations of the graphics library (sprites must be marked before the compilation stage of the engine) I pre-marked the sprite set into blocks (it seems to me the most commonly used sizes).
Each block has a number from 0 to 25. The total score is 26 different sprites.

1)Animation size is limited only by the number of sprites themselves (26).You can make animation from at least all sprites at once.
But then they will be displayed each of its size. At top of the spriteset, you can see group of sprites wih numbers from 0 to 3. They are all of same size and can be used for animation up to 4 frames.

2) Area is fixed, unfortunately.
But for more difficult animations you can use scripts.
For example, here is a spriteset from on level of the game that I working now.
Image
At left-bottom corner you can see 4 sprites. Two from them has size 32*8 and two has size 32*16.
Depending on the situation, I switch them from script.
Object itself moved up by 8px, but the material map is not updating, and player does not notice the substitution.
Image
3)I just could not figure out which sprite to draw there and mark the areas with crosses. These are the same sprites as everyone else. :)
And another one related to map definition. I see that there is a 'layer' property on each tile. Can i make an effect of dizzy waking behind objects? Like in the attache picture, where Dizzy is behind that plant.
Layers work only within their groups. A dynamic object with a layer of 1 will be drawn above a static object with a layer of 7. Sprite objects are drawn above the dynamic ones, and the player is drawn above all, the very last.
Ps. Projects statistics is a very useful tool, it helped me a lot with optimization of memory usage for graphics.
Yep, I regularly use it to control the size of the map.