|
-
Mar 9th, 2001, 06:03 AM
#1
Thread Starter
Retired VBF Adm1nistrator
Git ; No I didnt
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Mar 9th, 2001, 06:09 AM
#2
Addicted Member
I figured out part of the problem from Plenderj's project, and Kedaman's post... Now the offsets are basically 100* the scale of the map (aka an offset of 10,9 is 1000,900).
I'm still having problems though, i can only go in the direction of about 315 degrees. Here's my source.
Code:
Do
GameForm.Cls
If GetAsyncKeyState(vbKeyLeft) Then
Cars(PlayerCar).Angle = Cars(PlayerCar).Angle - 1
If Cars(PlayerCar).Angle < 1 Then Cars(PlayerCar).Angle = 360
ElseIf GetAsyncKeyState(vbKeyRight) Then
Cars(PlayerCar).Angle = Cars(PlayerCar).Angle + 1
If Cars(PlayerCar).Angle > 360 Then Cars(PlayerCar).Angle = 1
End If
If GetAsyncKeyState(vbKeyUp) Then
XOffSet = XOffSet + Int((Sin(100 * Cars(PlayerCar).Angle * 1.74532925199433E-02)))
YOffSet = YOffSet + Int((Cos(100 * Cars(PlayerCar).Angle * 1.74532925199433E-02)))
End If
Dim XTemp2 As Integer
Dim YTemp2 As Integer
XTemp2 = 0
YTemp2 = 0
For XTemp1 = 1 + Fix(XOffSet / 100) - Fix((GameForm.ScaleWidth / 100) + 1) To 1 + (XOffSet / 100) + Fix((GameForm.ScaleWidth / 100) + 1)
XTemp2 = XTemp2 + 1
YTemp2 = 0
For YTemp1 = 1 + Fix(YOffSet / 100) - Fix((GameForm.ScaleHeight / 100) + 1) To 1 + (YOffSet / 100) + Fix((GameForm.ScaleHeight / 100) + 1)
YTemp2 = YTemp2 + 1
If XTemp1 < 0 Or YTemp1 < 0 Or XTemp1 > MapXSize Or YTemp1 > MapYSize Then
Else
BitBlt GameForm.HDC, (Fix(XOffSet / 100) * 50) - XOffSet + ((XTemp2 - 1) * 50), (Fix(YOffSet / 100) * 50) - YOffSet + ((YTemp2 - 1) * 50), 50, 50, PicSource(0).HDC, (Map(XTemp1, YTemp1, 1).Type - 1) * 50, 0, vbSrcCopy
BitBlt GameForm.HDC, (Fix(XOffSet / 100) * 50) - XOffSet + ((XTemp2 - 1) * 50), (Fix(YOffSet / 100) * 50) - YOffSet + ((YTemp2 - 1) * 50), 50, 50, PicSource(1).HDC, (Map(XTemp1, YTemp1, 1).Type - 1) * 50, 0, vbSrcCopy
End If
Next YTemp1
Next XTemp1
Dim CarWidthOffsetCount As Integer
Dim CarWidthOffsetWidth As Integer
CarWidthOffsetWidth = 0
For CarWidthOffsetCount = 1 To PlayerCar - 1
CarWidthOffsetWidth = CarWidthOffsetWidth + CarTypes(CarWidthOffsetCount).Width
Next CarWidthOffsetCount
'CarBlitCodeHere
GameForm.Refresh
Sleep 50
DoEvents
Loop
Anyone know what's wrong? FYI the Sleep 50 is in there cause this is a BIT fast on my Duron 800.
Last edited by git; Mar 9th, 2001 at 06:13 AM.
-
Mar 9th, 2001, 06:14 AM
#3
Thread Starter
Retired VBF Adm1nistrator
Well...
Why not just copy the code out of Craft and blit your car instead of a spaceship 
Anyway, in relation to the Sleep part, why dont you use some GetTickCount().
IMHO, Thats the best way of slowing down games.
- jamie
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Mar 9th, 2001, 09:42 AM
#4
Thake a look at my "Dilemma" post. its somwhere on thise forum. It should help you out (try both formulas that are there, the one that shouldnt work, and the one that makes sense). Also, there is code in there to create a lookup table, so you dont have to call sin and cos (they are slow). Hope that helps.
Also, 1.74532925199433E-02 = PI / 180. Make your life easy, and create a constant. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|