Jump to content

TRON (game)


CodyBarrett
 Share

Recommended Posts

UPDATE!!

added a picture & put in a stupid and very inefficient way of deleting a character from the grid, just removes all the graphics, and redraws everything except the deleted player. :) anyone have a better idea?

Link to comment
Share on other sites

I don't know if it's better, but one thing you could do is draw every player to his own "buffer", then when a player dies you just stop drawing that buffer to screen.

Link to comment
Share on other sites

i'll try it in an hour or so... might be faster than before considering i'm recreating every player and every grid line when a player crashes. just deleting a single graphic for each player would work? can there be multiple graphics on the same window? are they transparent and overlapable?

hmmm.....

Link to comment
Share on other sites

Fixed the GDI graphics spasms. however i thinks its even slower... updated at the top.

Link to comment
Share on other sites

  • 4 months later...

NEW VERSION

completely rewritten, updated at the top, i've left the other scrips ive written for people to know how many attempts i've made with this, and how far its come along.

let me know if the new version has any bugs or needs improvements! :)

BTW, networking is still under development.

Link to comment
Share on other sites

draw_main() says "Use The Arrow Keys To Navigate:" but it listens to WASD!

Confusing!

Also the menu is almost uncontrollable because you have no Sleep() there, you only do it in the 'match' state!

It's a bit slow too, I would have preferred a smaller Sleep()!

You have some things to work on, but it's getting better!

And some extra exclamation marks for good measure: !!!!!

:)

Link to comment
Share on other sites

Oops. Forgot about that lol had the controls reversed then realized the players would be crossing over eachother to play.

Im not sure how to dynamically make the sleep() so it runs well on all machines. I had sleeps in the main and pick bike funcs and not in the match func but i couldnt navigate the bike at all without crashing. Too fast.

More tweaking.

Thanks admiral!

Link to comment
Share on other sites

You could use a timer-based approach.

Example using Sleep():

$iFPS = 60   ;FPS you want
$iColor = 0

ConsoleWrite("Asked for FPS: " & $iFPS & @LF)

;Calculate needed sleep
$iFPS = 1000 / $iFPS

AdlibRegister("_Exit", 5000)

$iTimer1 = TimerInit()   ;For calculationg actual fps
$iTimer2 = TimerInit()   ;For sleep
$iLoopCount = 0

While 1
    Do
        Sleep(10)
    Until TimerDiff($iTimer2) > $iFPS
    $iTimer2 = TimerInit()

    $iLoopCount += 1

    If TimerDiff($iTimer1) > 1000 Then
        $iTimer1 = TimerInit()
        ConsoleWrite("Actual FPS: " & $iLoopCount & @LF)
        $iLoopCount = 0
    EndIf
WEnd

Func _Exit()
    Exit
EndFunc

Not very good as it only works in 10ms steps.

_HighPrecisionSleep() (<--- link) is a lot better in this situation as it can go a lot lower (but 1ms is probably good enough, don't you agree? :)):

$iFPS = 60   ;FPS you want
$iColor = 0
$hDll = DllOpen("ntdll.dll")

ConsoleWrite("Asked for FPS: " & $iFPS & @LF)

;Calculate needed sleep
$iFPS = 1000 / $iFPS

AdlibRegister("_Exit", 5000)

$iTimer1 = TimerInit()   ;For calculationg actual fps
$iTimer2 = TimerInit()   ;For sleep
$iLoopCount = 0

While 1
    Do
        _HighPrecisionSleep2(1000, $hDll)
    Until TimerDiff($iTimer2) > $iFPS
    $iTimer2 = TimerInit()

    $iLoopCount += 1

    If TimerDiff($iTimer1) > 1000 Then
        $iTimer1 = TimerInit()
        ConsoleWrite("Actual FPS: " & $iLoopCount & @LF)
        $iLoopCount = 0
    EndIf
WEnd

Func _Exit()
    DllClose($hDll)
    Exit
EndFunc

; Original Name...........: _HighPrecisionSleep()
; Parameters .............:  $iMicroSeconds        - Amount of microseconds to sleep
; Original Author ........: Andreas Karlsson (monoceres)
; Heavely edited by ......:Alexander Samuelsson (AdmiralAlkex)
Func _HighPrecisionSleep2($iMicroSeconds, $hDll)
    Local $hStruct
    $hStruct=DllStructCreate("int64 time;")
    DllStructSetData($hStruct,"time",-1*($iMicroSeconds*10))
    DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct))
EndFunc
Link to comment
Share on other sites

thats interesting, both of them, the first would be usefull for games, and the second, wow, a NANOseconds? thats impressive... but, i'm still looking for, say a dynamic sleep-speed optimized for pcs, depending on the CPU speed? it runs (currently) fine on my 3ghz single core x86, but on my buddies machine its much faster, dual-core 2.6ghz x64. i'd like to make the run-time speeds equal for any machine.

Link to comment
Share on other sites

Maybe run some kind of system benchmark when the game starts to dynamically adjust your sleep? Like do some mathematical calculation, see how long it takes, and use that to guestimate how fast the machine is. It won't be perfect, but might get you close.

Link to comment
Share on other sites

i've updated the Download link with some minor changes, including a simple? sleep calculation. is that what you've been looking for?

Link to comment
Share on other sites

Why are you basing the speed on @CPUArch? That makes no sense. Granted, x64 apps are faster, but you need x64 AutoIt (@AutoItX64) for that, a x64 cpu is irrelevant as the user could be on a x86 OS or run x86 AutoIt.

And I gave you dynamic sleep above. Did you look at the scripts I posted?

Link to comment
Share on other sites

i did, the first one slowed it down so much that a sleep wasn't necessary while getting the timer diffs in its own DO LOOP.

and the second didn't seem usefull as i need a dynamic, not a precise sleep.

Link to comment
Share on other sites

You are missing my point! :)

$iTimer2 = TimerInit()
    
    ;Your script here

    $iLoopCount += 1

Clearer now? Only sleep for as long as necessary

Link to comment
Share on other sites

i believe so, its MUCH faster on my machine now... is it too fast for you guys? (updated the DL link)

thanks admiral

Link to comment
Share on other sites

While True
    If $State = 'main' Then
        Sleep (75)
        main ()
    ElseIf $State = 'pick_bike' Then
        Sleep (75)
        pick_bike ()
    ElseIf $State = 'match' Then
        Start_Cycle_Sleep ()
        match ()
        Finish_Cycle_Sleep ()
    EndIf
WEnd

this fixes it for MY machine, what about yours?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...