Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Optimizing Graphic Input? (Completed)
#1
So, I believe this has been discussed before, if I remember correctly. But I just want to know one thing.

Currently the map is being blited with information from the GameLoop. With call bltMask etc.. So it most go from x=0 to max_mapx. But instead of doing that. Can't you make it so it simply only draws the area around the char. For example:

Code:
For x = GetPlayerX(index) - 2 to GetPlayerX(index) + 2
  For y = GetPlayerY(index) - 2 to GetPlayerY(index) + 2
    ' The blitting part..
  Next y
Next x

Would that work, Im in school now so I don't know the correct name for call bltMask and such.
Reply
#2
Wouldn't this be "Optimizing Graphic Output"? :wink:

Anyways, that is probably there to draw objects larger then 32x32. Though, you wouldn't have to check to the right or down, since (I am guessing) the tile specified, in a say 64x64 image, is the top-left corner of the image. Actually now that I mention it, can MS even draw > 32x32 or just one size? Confusedhock:

You can just add in an extra rectangular check, Image vs Screen, to see if the drawing is even needed, before drawing.
Reply
#3
Yeah, Ill look into it Smile
Reply
#4
So here I have some work I've done. It's not yet complete so Ill submit the finish code later. So you guys can decide if it has been optimized:
Completed!
Replace this:
Code:
For y = 0 To MAX_MAPY
                For x = 0 To MAX_MAPX
                    Call BltTile(x, y)
                Next x
            Next y
With this:
Code:
' Blit out tiles layers ground/anim1/anim2
        If InEditor Then
            For y = 0 To MAX_MAPY
                For x = 0 To MAX_MAPX
                    Call BltTile(x, y)
                Next x
            Next y
        Else
            yChange1 = 2
            yChange2 = 2
            xChange1 = 2
            xChange2 = 2
            
            If GetPlayerY(MyIndex) - 2 < 0 Then yChange1 = 1
            If GetPlayerY(MyIndex) + 2 > MAX_MAPY Then yChange2 = 1
            If GetPlayerX(MyIndex) - 2 < 1 Then xChange1 = 1
            If GetPlayerX(MyIndex) + 2 > MAX_MAPX Then xChange2 = 1
            
            If GetPlayerY(MyIndex) - 1 < 0 Then yChange1 = 0
            If GetPlayerY(MyIndex) + 1 > MAX_MAPY Then yChange2 = 0
            If GetPlayerX(MyIndex) - 1 < 0 Then xChange1 = 0
            If GetPlayerX(MyIndex) + 1 > MAX_MAPX Then xChange2 = 0
            
            For y = GetPlayerY(MyIndex) - yChange1 To GetPlayerY(MyIndex) + yChange2
                For x = GetPlayerX(MyIndex) - xChange1 To GetPlayerX(MyIndex) + xChange2
                   Call BltTile(x, y)
                Next x
            Next y
        End If

Also add this at the top of the Sub:
Code:
Dim xChange1 As Byte, xChange2 As Byte, yChange1 As Byte, yChange2 As Byte
Now will this speed it up?

Also this has to be done for the fringe too.. And also a system that blts over the text area. I can do all those, I just need to know if this will speed anything up first.
Reply
#5
I don't get what it does..

Care to explain a bit?
Reply
#6
Sure. The old system blits everything through the GameLoop. So even on the places that hasnt changed, still blits.

For example, when only one player is on a map, with no enemy. The map is being reblited all the time. But with this system, it will only blit the tiles around the character, since those are the only onse that changes.

It's pretty meaningless to blt everything all the time, therefor I made this code that will blt up to 2 tiles around the character. Instead of all tiles on the whole map.

This results in a smaller For loop, and also less use of FastBlt(). So it will make some difference after all.

Even so, a lot of things needs to be added for this to work. You can see those things in the Tutorial section. I will complete the tutorial tomorrow i think. So you can test it then.
Reply
#7
Okay. Thanks for explaining.

Sounds like a good idea.
Reply
#8
Yeah, Obsidian did some explaining in the other topic. There are better ways to do it, but this is the only way I know, therefor I'll make this tutorial. So if Verrigan releases a better one later on. You can simply just change it to his instead Smile
Reply
#9
If people used this, and if someone created a tutorial to remove the fps cap and still have charcters move as they should.. This could be a very powerful thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)