Jump to content

Flickering Pics


Recommended Posts

Can anyone tell me how to fix the flickering graphics in this script? Thanks in advance.

#include <GUIConstants.au3>
#include <Misc.au3>

GUICreate ( "Starship Battles", 220, 320 , -1, -1, $WS_POPUP)
GUISetBkColor ( 0x000000 )
$ShipType = "Galaga"
$SLeft = 100
$STop = 305
$Ship = GUICtrlCreateIcon ( @ScriptDir & "\Icons\Galaga.ico", -1, $SLeft, $STop - 30 )
$ATopStart = 20
$ALeft1 = 30
$ALeft2 = 70
$ALeft3 = 110
$ALeft4 = 150
$ALeft5 = 190
$ACount = 0
$ShotNum = 0
$SpaceTop = -300
$Space = GUICtrlCreatePic ( @ScriptDir & "\Pictures\Space.bmp", 10, $SpaceTop, 200, 600 )
$Border1 = GUICtrlCreateLabel ( "", 0, 0, 220, 10 )
$Border2 = GUICtrlCreateLabel ( "", 0, 310, 220, 10 )
$Border3 = GUICtrlCreateLabel ( "", 0, 0, 10, 320 )
$Border4 = GUICtrlCreateLabel ( "", 210, 0, 11, 320 )
GUICtrlSetBkColor ( $Border1, 0x990000 )
GUICtrlSetBkColor ( $Border2, 0x990000 )
GUICtrlSetBkColor ( $Border3, 0x990000 )
GUICtrlSetBkColor ( $Border4, 0x990000 )

GUISetState ( )

SplashTextOn ( "Starship Battles", "Press S to change ships, the arrow keys to move, and space to fire.", 500, 50, -1, -1, 1 )
Sleep ( 5000 )
SplashOff ( )

$ATime = TimerInit ( )

While 1
    $msg = GUIGetMsg ()
    If $msg = $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    If _IsPressed ( 25 ) Then
        $SLeft = $SLeft - 3
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If _IsPressed ( 27 ) Then
        $SLeft = $SLeft + 3
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If _IsPressed ( 26 ) Then
        $STop = $STop - 3
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If _IsPressed ( 28 ) Then
        $STop = $STop + 3
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If _IsPressed ( 20 ) Then
        If $ShotNum = 0 Then
            $ShotLeft = $SLeft + 7
            $ShotTop = $STop - 20
            $Shot = GUICtrlCreatePic ( @Scriptdir & "\Pictures\Shot.bmp", $ShotLeft, $ShotTop, 16, 16 )
            $ShotTime = TimerInit ( )
            $ShotNum = 1
        EndIf
    EndIf
    If TimerDiff ( $ATime ) = 750 Then
        $APlace = Random ( 1, 5, 1 )
        If $APlace = 1 Then
            If $ACount = 0 Then
                $A1Top = $ATopStart
                GUICtrlCreateIcon ( @ScriptDir & "\Icons\Asteroids.ico", -1, $ALeft1, $A1Top )
                $ACount = 1
            EndIf
        ElseIf $APlace = 2 Then
            If $ACount = 1 Then
                $A2Top = $ATopStart
                GUICtrlCreateIcon ( @ScriptDir & "\Icons\Asteroids.ico", -1, $ALeft2, $A1Top )
                $ACount = 1
            EndIf
        EndIf
    EndIf
    If $ShotNum = 1 Then
        $ShotTop = $ShotTop - 4
        GUICtrlSetPos( $Shot, $ShotLeft, $ShotTop )
        If $ShotTop < 10 Then
            GUICtrlDelete ( $Shot )
            $ShotNum = 0
        EndIf
    EndIf
    If $STop < 10 Then
        $STop = 10
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If $STop > 305 Then
        $STop = 305
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If $SLeft < -5 Then
        $SLeft = 200
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If $SLeft > 200 Then
        $SLeft = 2
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
    EndIf
    If _IsPressed ( 53 ) Then
        GUICtrlDelete  ( $Ship )
        If $ShipType = "Galaga" Then
            $Ship = GUICtrlCreateIcon ( @ScriptDir & "\Icons\Rocket ship.ico", -1, $SLeft, $STop )
            $ShipType = "Rocket"
        Else
            $Ship = GUICtrlCreateIcon ( @ScriptDir & "\Icons\Galaga.ico", -1, $SLeft, $STop )
            $ShipType = "Galaga"
        EndIf
        Sleep ( 200 )
    EndIf
    $SpaceTop = $SpaceTop + 2
    GUICtrlSetPos ( $Space, 10, $SpaceTop, 200, 600 )
    GUICtrlSetPos ( $Ship, $SLeft, $STop )
    If $SpaceTop > 0 Then
        $SpaceTop = -300
        GUICtrlSetPos ( $Space, 10, $SpaceTop, 200, 600 )
        GUICtrlSetPos ( $Ship, $SLeft, $STop )
        GUICtrlSetPos ( $Border1, 0, 0, 220, 10 )
        GUICtrlSetPos ( $Border2, 0, 310, 220, 10 )
        GUICtrlSetPos ( $Border3, 0, 0, 10, 320 )
        GUICtrlSetPos ( $Border4, 210, 0, 11, 320 )
    EndIf
    If _IsPressed ( "1B" ) Then
        Exit
    EndIf
WEnd
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...