Posts ID:920845 Favorites Creations
 ID:920845   Aug 9 2012, 12:41 am (See the best response by DarkCampainger.) I'm currently working on a project that uses big icons to represent things like trees. I'm allowing the player to rotate the viewport of the client, which is kind of a nice feature, but it has some problems. When using icons larger than the grid cell size, the icons being offset from the bottom-left of the cell are actually causing the object to jump around in apparent location when rotated. I'm using a method to overcome this, by splitting the object into 4 directional states, each one only visible in one direction (North, south, east, and west). Then generating four visual objects to be used as overlays, and placing them in the overlay objects of the original, and manually offsetting them by certain values so that they always line up exactly where they should based on what I consider to be the "base" of the icon. Is there a better way to work around this? Or have I hit one of those strange things where DM wasn't made to do that, and as such, the workaround is all I can do?
 #1 Aug 9 2012, 12:51 am Best response Can you make your icon dimensions a square and center the "origin" of the actual content for each direction in the center? It'll increase the memory usage of your game a bit depending on how large the icons are (but not resource size), but it's a simpler solution. Then you can use bound_width/height/x/y (in tile-size increments if you aren't doing pixel-movement) to set the actual dense areas.
I... Don't see why I can't. Now why didn't I think of that?

 var list/multitiles = list()proc multitile_object(var/atom/o,var/icon,var/state,var/nl,var/w,var/incself=TRUE) var/obj/no var/tx = round(w/world.icon_size) var/nx = w/2 if(tx%2==1) nx -= world.icon_size/2 else nx -= world.icon_size nx *= -1 if(multitiles.Find("\ref[icon]:[state]1")) if(!incself) if(!multitiles.Find("\ref[icon]:[state]2")) no = new/obj() no.icon = icon no.icon_state = "[state]2" no.layer = nl no.pixel_x = nx multitiles["\ref[icon]:[state]2"] = no for(var/tdir=1;tdir<=8;tdir*=2) if(incself&&tdir==2) o.pixel_x = nx o.layer = nl o.icon_state = "[state][tdir]" continue no = multitiles["\ref[icon]:[state][tdir]"] o.overlays += no else for(var/tdir=1;tdir<=8;tdir*=2) if(incself&&tdir==2) o.pixel_x = nx o.layer = nl o.icon_state = "[state][tdir]" continue no = new/obj() no.icon = icon no.icon_state = "[state][tdir]" no.layer = nl if(tdir==1) no.pixel_y = nx*2 else if(tdir==4) no.pixel_x = nx*-1 no.pixel_y = nx else if(tdir==8) no.pixel_x = nx no.pixel_y = nx multitiles["\ref[icon]:[state][tdir]"] = no o.overlays += noobj tree icon = 'tree.dmi' icon_state = "trunk2" layer = 2 pixel_x = -16 density = 1 New() . = ..() spawn() global.multitile_object(src,'tree.dmi',"trunk",2,48) global.multitile_object(src,'tree.dmi',"top",800,48,FALSE) return . 

Fixed by "make squares". Thank you, Dark.
 #3 Aug 9 2012, 1:05 am Haha, yea. Welcome back, by the way.
 #4 Aug 9 2012, 1:16 am (Edited on Aug 9 2012, 1:39 am) Thanks! No place like it. Also, Just implemented the fix, and commented out my old code (Just in case). The old icon file was 17kbytes. The new one is 922 bytes. The old icon was 48x48 (3x3), and the new is 80x80 (5x5). I was using 1 object per tree and 3-4 overlay objects per unique multitile object layer. Meaning, this just dropped me down to 1 object per tree, and 1 overlay object per tree archetype. Considering I've got six types of trees in my game, that drops the object overhead by 42. Thanks again! This makes my life a lot easier.