Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   Playing with polygons (https://www.graalians.com/forums/showthread.php?t=7017)

Emera 05-31-2012 11:46 PM

Well, my primary goal was to create an updating bigmap using polygons to draw the tiles of the level (or gmap) you were in and scale it down so players could see where other players where on the map. That worked fantastically, and I managed to pull off a lag-free version using GUI controls. After I did this though, I got really bored. I started drawing polygons over the level and adding spinning effects and such to them to see what I could come up with.

The result of this was quite strange, and there was an endless range of effects I could pull off by doing this. In a nutshell, I'm drawing an individual 16 x 16 polygon across each tile within the level and setting the image to the tile set in use. After doing this, I positioned each 16 x 16 polygon, now set to the image of the tile at its point in the level, next to each other to form a collection of polygons that look effectively like the level you're in.

Since you can apply effects such as spin, alpha changing, zooming and rgb changes to polygons, I started to experiment with some simple maths. After a while, I found I could pull off some pretty neat effects.

The method used to draw these polygons is very laggy, and there are other ways of doing it. The reason I did it this way is because I wanted to manipulate every individual tile and add it separate effects.

Me and Suka tested this on Delteria and had an hour of fun just by watching what kind of things I could make these polygons do. I decided to video it since you can't really get a decent understanding of what I'm trying to talk about here just by looking at screen shots. If anybody would like to look at the code, I can post it here. For now though, I'll just post the video.

There's really no use to any of this apart from a little creative fun. Thanks for reading :)



Skip to 5:50 for the cooler stuff :)

Rexx 06-01-2012 12:21 AM

http://i47.tinypic.com/20fz4o7.gif

Dylan 06-01-2012 12:25 AM

Nice! It looks awesome.

Dusty 06-01-2012 01:19 AM

If this is just for a single level, you could have rendered it to a drawingpanel and then saved the image and used that either on a single polygon or just as an image itself :)

Emera 06-01-2012 07:46 AM

Quote:

Posted by Dusty (Post 130539)
If this is just for a single level, you could have rendered it to a drawingpanel and then saved the image and used that either on a single polygon or just as an image itself :)

I used that method for the map I made, but I wasn't sure if I could pull off effects like this with it. Thank you for your help with explaining how to make the map using the drawing panel though!

escolio 06-01-2012 08:21 AM

That looks cool!

Dusty 06-01-2012 05:06 PM

Quote:

Posted by Emera (Post 130835)
I used that method for the map I made, but I wasn't sure if I could pull off effects like this with it. Thank you for your help with explaining how to make the map using the drawing panel though!

Well it depends, you have access to modifiers like spin/rotation. You can also cut it into showimgs that run much better than polygons. Or just slap the entire image onto a single polygon and rotate it like that.

Also, here's the script I used to prerender my levels in Mode7:
PHP Code:

function PreRenderLevel() {
  
temp.mw int((player.gmap.width player.gmap.width 64)/64);
  
temp.mh int((player.gmap.height player.gmap.height 64)/64);

  for (
temp.client.mode7render) {
    if (
getimgwidth(i) > 0deletefile(i);
  }

  
client.mode7render = new[0];
  
temp.lvlprefix "dusty/mode7/lvl_" int(timevar2);

  
temp.originalx player.x;
  
temp.originaly player.y;
  
temp.ir this.imgresolution;
  new 
GuiDrawingPanel("Dusty_Mode7_prerender") {
    
useownprofile true;
    
profile.modal false;  
    
0;
    
width height 1024/ir;
    
alpha 0;

    
clearall();

    for (
temp.w=0;w<mw;w++) {
      for (
temp.h=0;h<mh;h++) {
        
playerx w*64+32;
        
playery h*64+32;
        
clearall();
        for (
temp.i=0;i<64;i++) {
          for (
temp.j=0;j<64;j++) {
            
temp.TilesToImage(tiles[w*64+i,h*64+j]);
            
//drawimagerectangle(i*16/ir,j*16/ir,thiso.mode7tileset,624,336,16,16);
            
drawimagestretched(i*16/ir,j*16/ir,16/ir,16/ir,thiso.mode7tileset,t[0],t[1],16,16);
          }
        }
        
temp.filename lvlprefix "_" "_" ".png";
        
saveimage(filename);
        
client.mode7render.add(filename);
        
waitfor(name,"bleh",0.05);
      }
    }
  }

  
Dusty_Mode7_prerender.destroy();

  
player.originalx;
  
player.originaly;


Using drawimagestretched like I did, you can stretch the portions you're drawing to the drawingpanel down to half/quarter sizes to map a smaller map with the limit space.

There are problems I've had with saving images intended to be used in-game in that it doesn't seem to like properly reloading the new image when generated with script. That is why I alway save my images with a unique prefix(in this case using timevar2). But if you do it like this you have to remember to clean up the old images. That's why I store the ones I'm generating into a client string and then loop through that on the next run and delete them all.

Emera 06-01-2012 05:17 PM

That makes more sense than what I was doing.
PHP Code:

function onRender() {
  
temp.tw = -1;
  
temp.th 0;

  for (
temp.064 64temp.i++) {
    if (
temp.tw 64) {
      
temp.tw 0;
      
temp.th++;
    } else {
      
temp.tw++;
    }

    
with(findimg(200 i)) {
      
polygon = {
        
temp.twtemp.thtemp.tw 1temp.thtemp.tw 1temp.th 1temp.twtemp.th 1
      
};

      
temp.tw;
      
temp.th;
      
image gettileset();

      
//Trimming
      
partx TilesToImage(tiles[temp.twtemp.th])[0];
      
party TilesToImage(tiles[temp.twtemp.th])[1];
      
partw 16;
      
parth 16;

      
//Effects
      
layer 0;
      
spin 1;
      
alpha 1;
    }
  }


Thanks for the help Dusty, I'll play around with this for a while and see what I can do. I take it this doesn't produce anything near the lag my code produces? (Also, I've been using your wonderful TilesToImage function. Thank you)

xSuka 06-01-2012 10:31 PM

lol. :D


All times are GMT. The time now is 02:47 AM.

Powered by vBulletin/Copyright ©2000 - 2026, vBulletin Solutions Inc.