Project X Forums
http://px.worms2d.info/forum/

Create destructible terrain to landscape, with code?
http://px.worms2d.info/forum/viewtopic.php?f=13&t=2087
Page 1 of 1

Author:  Resurrection [ Sat Aug 13, 2016 1:26 pm ]
Post subject:  Create destructible terrain to landscape, with code?

Javelin lib have a way to draw sprites on terrain but this is not what i mean.
Is there a way to draw *new* terrain, just like girder does but trough code?

This seems like something trivial, its a game about destroying terrain after all.
But i cant find any topic or even a library .. except for CLandscape which has the functions to create holes.

Author:  Zed [ Sat Aug 13, 2016 8:55 pm ]
Post subject:  Re: Create destructible terrain to landscape, with code?

Javelin lib and possessed lib both create landscape. You can do girder, or any sprite. Here short guide:


0) Add sprite similarly to aforementioned libs (for simplicity try 1frame, like possessed.pxl does).
Code:
require utils;
CBitmap32* girderv2Bitmap;
void possessed::InitGraphic()
{
    local spr       = GetAttachment("girderv2.png");     
    girderv2Bitmap     = LoadImage(spr);
}

1) Create copy of teleport weapon (lets name it "girder v2").
2) At firefinal checkname("girder v2"), if true ->

local bmp = girderv2Bitmap;
GG->land->Draw(bmp, SelectX/65536;, SelectY/65536;));
3) return, so teleport would not trigger. My hns lib operates with fake teleport weapons btw.
4) super afterwards, for all weapons that are not named "girder v2"

If you want a method to smoothly draw terrain, you can create it using sprites, similarly to steps' painter.

Author:  Resurrection [ Sun Aug 14, 2016 12:40 pm ]
Post subject:  Re: Create destructible terrain to landscape, with code?

I watch the replay of possessed and the shield is drawn as terrain but my code is not working, it only drawn on top of existing terrain.

Edit: The problem was its not drawing outside map boundaries. This is an issue because mole maps cant have crates spawning at roof.

Author:  Zed [ Sun Aug 14, 2016 1:02 pm ]
Post subject:  Re: Create destructible terrain to landscape, with code?

Use bigger map? I don't think girder can be put outside of the map boundaries as well.

I'm not sure, but it may be possible to create fake terrain, by creating 1x1 object that will represent a pixel, and recreate all terrain behavior in it's code. It is might lag the game out though...

edit: i realized what you mean by "crates that are spawning on roof". Maybe custom spawning manager will help? Instead of regular spawns, using scripts to put crates at random locations not on top of the map. This is pretty complex solution though :D. Maybe catch all crates that are spawning on "roof" (if y < i) and teleport them at random locations "under roof" is easier. This will require landscape checking, similar to the one in codesnippets..

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/