Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread of questions
#16
It's all good while your learning, if something like that works go with it.
On to the next questions, I know the first two, but I might stumble on the last one this time, my DirectX isn't great either:

1) I suppose the best answer is yes, many of the code operations(correct term?) you'll come across just boil down to being able to write a whole lot of code in the least amount of lines.
The For/Next loop as it's called is an excellent way of doing this, let me know if you'd like a better explanation of this one.

2)The TickCount is the representation of a timeframe as measured by the computer, each Tick is the equivalent of approximately 1 millisecond, therefore 1000 Ticks are equivalent to about 1 second. I think I'm right in saying that the computer starts to measure its TickCount right from the time that it boots up, have a look in modDeclares and you'll see that GetTickCount is declared as a function from the "kernel32" library.
Now, using that knowledge you can see that GSD2 = GetTickCount takes a single point in time from the computers 'stopwatch' if you like to compare with another point in time somewhere else in the code.
I'm pretty sure you understand how the For/Next loop works to actually blit the NPC's hit bars, so I'll just run you through the first section of the code you posted.

Dim GSD2 As Long
- Create a variable of type Long called GSD2 to hold a value.

If GetTickCount > GSD2 + 500 Then
- If the (time on the computers 'stopwatch') is greater than (the variable GSD2's value + 500) Then execute the following code.

Call SendData("getnpchp" & SEP_CHAR & END_CHAR)
- sends a packet to the server asking for all Npc's current HP values.

GSD2 = GetTickCount
- take the value in the computers 'stopwatch' and enter it into the variable GSD2

put basically what this does, is send a packet to the server every half a second requesting an update to the Npc's HP values, to which the server replies with the packet from your first question.
I'm not sure I like this way of doing it personally, seems a bit wasteful, but I'm not willing to rewrite the tutorial so we'll go with it.

---------------
Before I go on, how am I doing?
Are the bold bits picking out all the relevant stuff properly?
Am I going over the top explaining stuff?
It'll give me an idea of where your at learning-wise so I can tailor things a little more to your level.
----------------

3) The BackBuffer is an area that the computer uses offscreen to put together everything before it displays the final 'frame' to the viewable area of the screen.
If you've got the fps counter working it'll give you an idea of how many times the computer runs through the gameloop every second!

The line
Code:
' Blit the backbuffer
Call DD_PrimarySurf.Blt(rec_pos, DD_BackBuffer, rec, DDBLT_WAIT)
in the gameloop is the bit responsible for taking a rectangle the size of rec from the BackBuffer and showing it on the monitor in the rectangle rec_pos.

I love VB's code completion thingie, in the visual basic IDE find and delete the first bracket after .Blt in the line of code above, now type it in again and VB should show you the values that the Sub/Function is expecting.

The x/y bit is all about finding where the left side(x) and the top edge(y) of the .DrawBox should be drawn.

MapNpc(Index).x * PIC_X
- How many tiles from the left side of the screen the Npc is.
+ MapNpc(Index).XOffset
- Plus how far left or right the Npc is if it's walking from one tile to the next.

The y value calculates where the top of the tile is that the Npc is on, the -4 bit makes sure the bar is blitted far enough above the Npc's head.

Hope that helps a bit. Big Grin
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)