Sign in to follow this  
Followers 0
CodyBarrett

currentposition of guictrlpic

3 posts in this topic

#1 ·  Posted (edited)

i think the title basically explains it.. but anyway im making a "SNAKE type of gui game based on arrow keymovments... and uhh i got the "FOOD" dot to reapear in a random place.. but how would i go about finding the current location of the "SNAKE" and adding pixels to it to make it move? this is my asic script (just started 30mins ago on this particualr project)

;############### Writen By Bob00037 ###############:
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

HotKeySet("{UP}", "up")
HotKeySet("{DOWN}", "down")
HotKeySet("{LEFT}","left")
HotKeySet("{RIGHT}","right")

$SNAKE = GUICreate("SNAKE",500,500)
$Ra = Random(10,490)
GUISetBkColor(0x0C0C0C)
$R = GUICtrlCreatePic("RED DOT.bmp",$Ra,$Ra, 10, 10)
$W = GUICtrlCreatePic("WHITE DOT.bmp",10,10,10,10)

GUISetState(@SW_SHOW)

up()
Func up()
EndFunc

down()
Func down()
EndFunc

left()
Func left()
EndFunc

right()
Func right()
EndFunc

While GuiGetMsg() <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
WEnd

any ideas on a func for the current location?

Edited by bob00037

Share this post


Link to post
Share on other sites



I did something like this in Java. What I would do is make a huge array of label controls and make them different colors. Or you could use images if you really want the objects to be circular. That way, when you create an apple, you can get it's coords, and each time you move, check the coords of the snake with the coords of the apple.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

what i really want is to make the SNAKE to start off moving downward like (GETPOS and then +10 pix) to the pos based on what key you press.. and IF 10000 milleseconds go by the red dot relocates...

Share this post


Link to post
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
Sign in to follow this  
Followers 0