Yes. The ship would be similar to how I make the player in the example swim on the surface of water if you press W (you can use wp_rectangle_get_volume). Splashing can be done by adding velocity to a specific point in the water (wp_rectangle_set_velocity). This is also done in the example code, when the player falls and lands in water. Or you can create custom splash sprites where the impact happens if you want the look of the splash effect to be different.Thanks got it running well. Is there a chance to make something like a ship swim on the surface or drawing wheels half in water to make water splashing like a watermill?
I'll take a look.This is a request, can you update text inputs for game-maker 2? The "#" key doesn't work, and I cant seem to fix it. I love it so much, please fix.
To fix the "#"-character issue yourself, you can do the following after importing the GM Studio 1 version into GM Studio 2:This is a request, can you update text inputs for game-maker 2? The "#" key doesn't work, and I cant seem to fix it. I love it so much, please fix.
Hi, this is all part of the example implementation. You don't really need to use the example code, it's just there to show you how you can use the asset. But if you want to start with the example code and try to form it into your own game, I recommend starting in obj_example_main. That's where most of the control code is. Take a look at obj_example_main's draw event if you want to see how things are drawn and remove certain parts. The GUI objects draw themselves. If you want to remove these, you can do so directly from the room.Hello! I just bought water physics.Because I want to add it to my game.i read GUIDE.But it's too difficult for me.I do not speak English well, but most of it was understandable.In the rm_example, I want to delete out the background and blocks and gui. how i to do it?
grid = ds_grid_create(room_width,room_height);
water_ = wp_rectangle_create(room_width,room_height,32,32,0,0,0,1,3,true,grid);
repeat(2) wp_rectangle_update_simulation(water_,grid);
wp_rectangle_set_volume(water_,mouse_x,mouse_y, 1, 1, 1, true);
wp_rectangle_draw(water_,x,y,0,0,0,0,0,0,0,0);
You should take a look at how the example does it and learn how DS grids work. I can see several things here that are wrong, such as using 0 and 0 for binding capacities in wp_rectangle_create, and using room_width and room_height as size for the DS grid. If you still have problems afterward, feel free to continue asking.So I bought this, but I have no idea of how to use it. I readed the guide and did what it said, but it doesn't work (I'm not using the example things). I'm probably doing everything wrong, so you'll have to help. : ) And I have never used ds grids before.
I have an object called control_water.
In the create event:
In the step event:Code:grid = ds_grid_create(room_width,room_height); water_ = wp_rectangle_create(room_width,room_height,32,32,0,0,0,1,3,true,grid);
In the draw event:Code:repeat(2) wp_rectangle_update_simulation(water_,grid); wp_rectangle_set_volume(water_,mouse_x,mouse_y, 1, 1, 1, true);
But there is no water anywhere.Code:wp_rectangle_draw(water_,x,y,0,0,0,0,0,0,0,0);
water_block_width = 32;
water_block_height = 32;
//Walls and grids
sf_walls[0] = -1;
sf_walls[1] = -1;
wall_width = 64;
wall_height = 64;
wall_grid_width = ceil(room_width/wall_width);
wall_grid_height = ceil(room_width/wall_height);
wall_grid = ds_grid_create(wall_grid_width,wall_grid_height);
water_ = wp_rectangle_create(ceil(room_width/water_block_width),ceil(room_height/water_block_height),water_block_width,water_block_height,0,0.7,0.7,1,3,false,wall_grid);
//Add water when pressing LMB
if mouse_check_button(mb_left) {
wp_rectangle_set_volume(water_,floor(mouse_x/water_block_width),floor(mouse_y/water_block_height),1,1,1,true);
}
// Update the physics simulation
repeat(2) wp_rectangle_update_simulation(water_,wall_grid);
wp_rectangle_draw(water_,x,y,0,0,0,0,0,0,0,0);
//Create block surfaces
for (var layer = 0; layer < 2; ++layer) {
if (!surface_exists(sf_walls[layer])) {
sf_walls[layer] = surface_create(room_width,room_height);
surface_set_target(sf_walls[layer]);
draw_enable_alphablend(false);
draw_clear_alpha(c_black, 0);
var t_x, t_y, color, grid = wall_grid[layer];
for (t_y = 0; t_y < wall_grid_height; ++t_y) {
for (t_x = 0; t_x < wall_grid_width; ++t_x) {
if (grid[# t_x, t_y] != 0) {
draw_sprite(sprite_wall,0,t_x * wall_width, t_y * wall_height);
}
}
}
draw_enable_alphablend(true);
surface_reset_target();
}
}
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object control_water:
trying to index a variable which is not an array
at gml_Object_control_water_DrawEvent_1 (line 10) - var t_x, t_y, color, grid = wall_grid[layer];
############################################################################################
Remove the code below "//Create block surfaces". That's just for visualization of dirt and stone blocks etc.I tryied to modify it and do it like in the example. I don't know if this is any better.
In the create event:
In the step event:Code:water_block_width = 32; water_block_height = 32; //Walls and grids sf_walls[0] = -1; sf_walls[1] = -1; wall_width = 64; wall_height = 64; wall_grid_width = ceil(room_width/wall_width); wall_grid_height = ceil(room_width/wall_height); wall_grid = ds_grid_create(wall_grid_width,wall_grid_height); water_ = wp_rectangle_create(ceil(room_width/water_block_width),ceil(room_height/water_block_height),water_block_width,water_block_height,0,0.7,0.7,1,3,false,wall_grid);
In the draw event:Code://Add water when pressing LMB if mouse_check_button(mb_left) { wp_rectangle_set_volume(water_,floor(mouse_x/water_block_width),floor(mouse_y/water_block_height),1,1,1,true); } // Update the physics simulation repeat(2) wp_rectangle_update_simulation(water_,wall_grid);
Code:wp_rectangle_draw(water_,x,y,0,0,0,0,0,0,0,0); //Create block surfaces for (var layer = 0; layer < 2; ++layer) { if (!surface_exists(sf_walls[layer])) { sf_walls[layer] = surface_create(room_width,room_height); surface_set_target(sf_walls[layer]); draw_enable_alphablend(false); draw_clear_alpha(c_black, 0); var t_x, t_y, color, grid = wall_grid[layer]; for (t_y = 0; t_y < wall_grid_height; ++t_y) { for (t_x = 0; t_x < wall_grid_width; ++t_x) { if (grid[# t_x, t_y] != 0) { draw_sprite(sprite_wall,0,t_x * wall_width, t_y * wall_height); } } } draw_enable_alphablend(true); surface_reset_target(); } }
And it showed this error:
What should I do?Code:___________________________________________ ############################################################################################ FATAL ERROR in action number 1 of Draw Event for object control_water: trying to index a variable which is not an array at gml_Object_control_water_DrawEvent_1 (line 10) - var t_x, t_y, color, grid = wall_grid[layer]; ############################################################################################
I did that. There is no more error messages. But there isn't water. How to add the water to the room?Remove the code below "//Create block surfaces".
It seems like the water is just not being drawn, because of all those zeros in wp_rectangle_draw. Set the arguments to undefined, or omit them like this: "wp_rectangle_draw(water_, x, y);"I did that. There is no more error messages. But there isn't water. How to add the water to the room?
You have to enter values for the walls into the DS grid so the water knows what it should collide with. That's the purpose of the DS grid.I did something and now there is a lot of water, but it seems that it doesn't collide with the walls. So, how to do that collision?
View attachment 14950
with (obj_wall) ds_grid_set(other.wall_grid, floor(x / other.wall_width), floor(y / other.wall_height), 1);
Try this instead:I added this:
Now there is some kind of colision, but it is in the wrong place, as you can see in the image:View attachment 14976Code:with(wall) { ds_grid_set(control_water.wall_grid,floor(x/control_water.wall_width),floor(y/control_water.wall_height),1); }
with(wall) {
ds_grid_set(control_water.wall_grid,floor((x - control_water.x)/control_water.wall_width),floor((y - control_water.y)/control_water.wall_height),1);
}
Now the collisions are relative or something. One is perfect and all above are too up and all below are too down.Try this instead:
It subtracts control_water's position so the cells get aligned to it.Code:with(wall) { ds_grid_set(control_water.wall_grid,floor((x - control_water.x)/control_water.wall_width),floor((y - control_water.y)/control_water.wall_height),1); }
Are all blocks in the room editor in the 64x64 grid? Try setting water_block_width and water_block_height to 64 as well and see if the problem persists. Are the block sprite's origin (0, 0)?Now the collisions are relative or something. One is perfect and all above are too up and all below are too down.
View attachment 15033
What that means?Are all blocks in the room editor in the 64x64 grid?
Tried and the problem persists.Try setting water_block_width and water_block_height to 64 as well and see if the problem persists.
Yes.Are the block sprite's origin (0, 0)?
It means that your blocks are aligned according to the room editor grid. 64x64 means the width and height of each cell in the grid is 64 pixels. None of them should be one pixel off compared to the others, they should all be a multiple of 64 pixels away from each other.What that means?
I'm sorry, I don't have time for that. The asset's example still works, so you can study it to find your mistake.If you can't figure out what is the problem, could you add this to my game?
Ok, so how do I know how they are?It means that your blocks are aligned according to the room editor grid. 64x64 means the width and height of each cell in the grid is 64 pixels. None of them should be one pixel off compared to the others, they should all be a multiple of 64 pixels away from each other.
If the room editor grid is set to 64x64 when you place down your object instances, they should automatically be aligned. To check if they're aligned, you can go through the instances' positions and check if x and y is a multiple of 64, but noone does this. You can read about the room editor grid in the manual if you don't know what it is.Ok, so how do I know how they are?
Which should be:Code:wall_grid_height = ceil(room_width/wall_height);
wall_grid_height = ceil(room_height/wall_height);
I changed that and then changed this:@Flyinglegend_Studio:
I believe the problem is in this line of code in your create event:
Which should be:
Code:wall_grid_height = ceil(room_height/wall_height);
Yes, it's possible to specify a rectangular region. All of the scripts are documented, so open the script and you should be able to figure it out.Hi. I'm here again. Sorry to bother you again. I have some problems using wp_rectangle_update_blocks. Is it possible to update everything instead of just one point? Because in my game sometimes many things in different places change. Thanks in advance.
I tried to do this when a wall gets destroyed:Yes, it's possible to specify a rectangular region. All of the scripts are documented, so open the script and you should be able to figure it out.
wp_rectangle_update_blocks(water_,wall_grid,0,0,wall_grid_width,wall_grid_height);
It looks correct. That will update all blocks in the grid though, so it might be a bit slow. Did you remember to set the cell in the grid back to 0 before calling the script?I tried to do this when a wall gets destroyed:
But it didn't work.Code:wp_rectangle_update_blocks(water_,wall_grid,0,0,wall_grid_width,wall_grid_height);
Oh. I didn't know I have to do something like that... : ) But I added now this to the walls destroy event:Did you remember to set the cell in the grid back to 0 before calling the script?
ds_grid_set(control_water.wall_grid,x,y,0);
Oh. I didn't know I have to do something like that... : ) But I added now this to the walls destroy event:
Is this right? Because it didn't work. But there are a lot of messages in the compile form. Like this:Code:ds_grid_set(control_water.wall_grid,x,y,0);
Grid 0, index out of bounds writing [1472,2944] - size is [32,47]
ds_grid_set(control_water.wall_grid, floor(x/control_water.wall_width), floor(y/control_water.wall_height), 0);
Now it works. Thanks!Code:
ds_grid_set(control_water.wall_grid, floor(x/control_water.wall_width), floor(y/control_water.wall_height), 0);
That's strange. Seems like the surfaces get deleted for some reason. Do you have an old graphics card? Do you know how much VRAM is on it? Although not a completely satisfactory solution, you can try to call wp_rectangle_surface_to_buffer once or twice a second. This sets a backup which will be used whenever the water disappears from surface deletion.Hi again. When the walls destroy, all the water disappears. How to prevent that from happening?
I don't know how much VRAM is on it, but it should be quite new and good.Do you have an old graphics card? Do you know how much VRAM is on it?
wp_rectangle_surface_to_buffer(water_);
Glad you got it to work. However, that's kind of a slow solution as it accesses external memory. You should be able to make it work with wp_rectangle_surface_to_buffer.Wait again. I got it to work. What I had to do, is alarm event with wp_rectangle_save_volume, and when a wall gets destroyed, wp_rectangle_load_volume.
EDIT: When a wall gets destroyed, water appears there without any reason. Why?
Ok. Thank you for the help.Glad you got it to work. However, that's kind of a slow solution as it accesses external memory. You should be able to make it work with wp_rectangle_surface_to_buffer.
In addition to updating blocks, wp_rectangle_update_blocks also adds inactive water behind blocks in order to make the outside water bind to the blocks. Otherwise you would see an unnatural curve next to the blocks. You can set the volume to 0 with wp_rectangle_set_volume after you destroy the wall.
Sorry, but no, I haven't worked on an isometric system.Do you have something similar for an isometric type of map wherein a portion of the body of water can be affected by external factors like a Weather System? For example, when a storm cloud is nearby, those water tiles in a specified area are more wavy and more turbulent, etc. Another example is, let's say there is a Tornado, the target water tile forms a whirlpool under it.
The error says you have a texture, likely the texture of a surface, with a dimension (width or height) greater than 16384 pixels. The problem is most likely because you have a very large world. The first thing you can do is to turn off surface optimization in the block lighting asset (look for the variable with a similar name to "surface optimization"). This will allow for 64x larger worlds as it no longer records a screenshot of the whole world, but only 1 pixel per block. It's still possible to use the assets with worlds exceeding this limit (even infinite worlds), but this requires more programming experience to implement, so it's easier to stay below the limit.Hello, I am interresetet in your Asset.
I tryed your Block Lightning 2d assest, but it crashes. So i am not sure, if the Water Physics will work.
The Problem ist, I will make a very very large world, with a 64x64px tileset. (Similar to the game Nom Nom Galaxy)
I get an error: "Atempting to create a texture of size blabla x blahbla in SetupD3DTexture, this is bigger than the maximum allowable dimension (16384)".
So my question: Will Water Physics work? (And also Fluid Dynamics)
English pleaseCompré el activo ayer, he estado intentando implementarlo en mi juego durante varias horas con la ayuda de la guía, pero ni siquiera puedo ver el agua, ¿no tienes ningún video sobre cómo implementarlo en cualquier juego? ¿Es solo la guía?