Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Drawing a level with GuiDrawingPanel (https://forums.graalonline.com/forums/showthread.php?t=134267790)

Emera 01-22-2013 03:54 PM

Drawing a level with GuiDrawingPanel
 
I'm having a bit of trouble drawing an image of a level using a GuiDrawingPanel control. The script draws the level's tiles, chops pics1.png up using Dusty's TilesToImage() function and then positions them on the panel to create an image of the level, but for some reason I'm having some strange issues. The saved image only manages to draw a single line of tiles instead of the whole level (look at the screen shot to see what I mean). Can anybody offer any suggestions on why it's doing this?

PHP Code:

//#CLIENTSIDE

function onCreated() {
  
this.panel = new GuiDrawingPanel();
  
this.panel.visible true;
  
this.panel.width 64 16;
  
this.panel.height 64 16;
  
this.panel.0;
  
this.panel.0;
  
this.panel.clearall();
  
  for (
temp.0temp.< (64 64); temp.++) {
    
temp.tilex = (64);
    
temp.tiley int(64);
 
    
temp.tile tiles[temp.tilextemp.tiley];
    
temp.imagetile tilestoimage(temp.tile);
    
    
temp.obj findimg(200);
    
temp.obj.image "pics1.png";
    
temp.obj.partx temp.imagetile[0];
    
temp.obj.party temp.imagetile[1];
    
temp.obj.partw 16;
    
temp.obj.parth 16;
    
    
this.panel.drawObject(temp.tilex 16temp.tiley 16temp.obj);
  }
  
this.panel.saveimage("tiles.png");
  
this.panel.destroy();
}

function 
TilesToImage(t) {
  if (
t.type() == 0) {
    
temp.px = (int(t%16)*16)+(int(t/512)*256);
    
temp.py = (int(t/16)*16)%512;
    return {
px,py};
  } else if (
t.type() == 3) {
    
temp.imgarray = new[0];
    for (
temp.t) {
      
temp.px = (int(i%16)*16)+(int(i/512)*256);
      
temp.py = (int(i/16)*16)%512;
      
imgarray.add({px,py}); 
    }
    return 
imgarray;
  } else return -
1;


Image Start
http://i.imgur.com/kr0qAR0.png
Image End

callimuc 01-22-2013 09:00 PM

something like this should work

PHP Code:

new GuiDrawingPanel("GuiNameHere") {
  
visible false;
  
resize(006464);
  
clearall();

  for (
temp.render_x 0temp.render_x 64temp.render_x ++) {
    for (
temp.render_y 0temp.render_y 64temp.render_y ++) {
      
temp.pl_x player.- (player.x%64); //get the starting point of the 64x64 tiles render (starting point of the level in this case; works on maps and insides)
      
temp.pl_y player.- (player.y%64); // ^
      
temp.tile_tiles tiles[ (temp.pl_x temp.render_x), (temp.pl_y temp.render_y) ];
      
temp.tile_image TilesToImage(temp.check_tile);
      
drawimagestretched(render_x*16render_y*161616getTileset(), temp.tile_image[0], temp.tile_image[1], 1616);
    }
  }
  
saveimage("ImageNameHere");
  
destroy();


if not, check dusty's mode7 thing, that helped me when i made my level displayer in a GUI (can be checked on Testbed, weapon name is 'Public/DustyPorViva/Mode7')


All times are GMT +2. The time now is 06:40 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.