Could someone explain this code?
BlitzMax Forums/BlitzMax Programming/Could someone explain this code?
| ||
Method render() Local drawY%, drawX% Local tOffY% Local gOffX% Local actualDrawX%, actualDrawY% For Local y% = 0 To Height - 1 tOffY = 0 For Local x% = 0 To width - 1 drawX% = x tOffY:+ 15 actualDrawX% = (((((((drawX * (TILEWIDTH + 2))) - ((TILEHEIGHT + 1) * x))) - (gOffx))) - x) + offsetx actualDrawY% = (((drawY * (TILEHEIGHT + 1)) + tOffY) + (y * (TILEHEIGHT / 2))) + offsety If actualDrawX < 0 - TILEWIDTH Or actualDrawY < 0 - TILEHEIGHT Or actualDrawX > GraphicsWidth() Or actualDrawY > GraphicsHeight() Then ' // Dont render if the tile is off screen Else If tile[x , y].blocked Then SetColor 255 , 0 , 0 DrawImage (floorImageSet, actualDrawX, actualDrawY, tile[x, y].floorStyle) SetColor 255, 255, 255 EndIf Next gOffX%:+ 30 Next For Local point:TPoint = EachIn pointList point.SetOffset(offsetx + (TILEWIDTH / 2), offsety + (TILEHEIGHT / 2)) point.render() Next End Method As you see its the drawing part of a isometric engine... So could someone explain for wath is each variable Oh and and the to DiabloGames for suplying the free sourcecode I'm trying to make my own isometric engine and I know some pinciples but I can't figure out this one |
| ||
Are you sure you're a programmer? I mean, it seems insanely n00bish to ask people to "explain this code to me" and "explain what each variable is for". Try changing things and see what happens. Put some effort into it first. |
| ||
It's some kind of tilemap drawing routine. |
| ||
Yeah but i was wondering if someone can explain how it works if not I will try more AND MORE TILL i DO UNDERSTAND IT BUT IT WOULD BE SIMPLER THIS WAY srry capslock |
| ||
apologising for caps only makes sense in a blog, or forum without edit-feature. What helps for me is to stop reading sources from others and simply try to make it yourself from scratch. You know the idea of an isometric map, from that you can easily think of a solution on how to display. Mind you, I don't know a hoot about how to incorporate moving things in such a map (cars, ppl etc.) other than brute-force redrawing the whole kab00z. |
| ||
if you can't figure this code on your own then you should not even bother with isometric land and go for flat maps till you get better |
| ||
I get the feeling Sanctus that you are in fact trying to get a collaberative team going? I havent come to this conclustion just from this post, but also from your graphics ones. This must be so, because this question is so mind numbingly stupid, it cannot be a real one. There isnt a single variable in that code that isnt addequetly named. What do you think "actualDrawX" means? |
| ||
I understood wath actualdraw was for but i didn't understand the tOffx and gOffy Now I got it working with a little help from a tut from Blitzcoder I got it working preety nice |
| ||
Actually a websearch will give you the information you need on isometric engines. And do use the edit feature instead of apologising for CAPS LOCK :) |
| ||
I was to lazy to write again :P |