Jump to content

picture help ?


Recommended Posts

i got a problem i made a little game where you need to avoid some boxes but!

the problem is i cant get it to work :S?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
hotkeyset ("{right}","right")
hotkeyset ("{left}","left")

$score=0
$1=24
$2=84
$3=136
$4=200
$5=384
$6=424
$7=512
$8=520
$9=80
$10=30
$11=120
$12=30
$13=90
$14=40
$15=130
$16=50
$top=410
$left=304
$level=1
$small=33
$normal=44
$big=55
$menormal=36
$movespeed1=2*$level
$movespeed2=5*$level
$movespeed3=10*$level
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetBkColor(0x800000)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\char.bmp", $left, $top, $menormal, $menormal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$label=GUICtrlCreateLabel("Score : "&$score,500,0,200,20)
$Pic2 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $1,  $9,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic3 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $2,  $10,$small, $small, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic4 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $3,  $11,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic5 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $4,  $12,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic6 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $5,  $13,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic7 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $6,  $14,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic8 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $7,  $15,$big, $big, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Pic9 = GUICtrlCreatePic(@ScriptDir&"\black.bmp", $8,  $16,$normal,$normal, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

EndSwitch

$score=$score+23*$level

guictrlsetdata($label,"Score : "&$score)

$9=$9+$movespeed2
$10=$10+$movespeed3
$11=$11+$movespeed2
$12=$12+$movespeed2
$13=$13+$movespeed2
$14=$14+$movespeed2
$15=$15+$movespeed1
$16=$16+$movespeed3
guictrlsetpos ($pic2,$1, $9,44,44)
guictrlsetpos ($pic3,$2,$10,33,33)
guictrlsetpos ($pic4,$3,$11,44,44)
guictrlsetpos ($pic5,$4,$12,44,44)
guictrlsetpos ($pic6,$5,$13,44,44)
guictrlsetpos ($pic7,$6,$14,44,44)
guictrlsetpos ($pic8,$7,$15,55,55)
guictrlsetpos ($pic9,$8,$16,33,33)

if $9=600 then
$firstrandom=random (0,7,1)
if $firstrandom=0 then $pos1=random (0,84,1)
if $firstrandom=1 then  $pos1=random (84,136,1)
if $firstrandom=2 then  $pos1=random (136,200,1)
if $firstrandom=3 then  $pos1=random(200,384,1)
if $firstrandom=4 then  $pos1=random (384,424,1)
if $firstrandom=5 then  $pos1=random (424,512,1)
if $firstrandom=6 then  $pos1=random (512,520,1)
if $firstrandom=7 then  $pos1=random (520,600,1)
$1=$pos1
$9=0
endif
if $10=600 then
$2random=random (0,7,1)
if $2random=0 then  $pos2=random (0,84,1)
if $2random=1 then  $pos2=random (84,136,1)
if $2random=2 then  $pos2=random (136,200,1)
if $2random=3 then  $pos2=random(200,384,1)
if $2random=4 then  $pos2=random (384,424,1)
if $2random=5 then  $pos2=random (424,512,1)
if $2random=6 then  $pos2=random (512,520,1)
if $2random=7 then  $pos2=random (520,600,1)

$2=$pos2
$10=0
EndIf
if $11=600 Then
$3random=random (0,7,1)
if $3random=0 then  $pos3=random (0,84,1)
if $3random=1 then  $pos3=random (84,136,1)
if $3random=2 then  $pos3=random (136,200,1)
if $3random=3 then  $pos3=random(200,384,1)
if $3random=4 then  $pos3=random (384,424,1)
if $3random=5 then  $pos3=random (424,512,1)
if $3random=6 then  $pos3=random (512,520,1)
if $3random=7 then  $pos3=random (520,600,1)
$3=$pos3
$11=0
endif


if $12=600 Then
$4random=random (0,7,1)
if $4random=0 then  $pos4=random (0,84,1)
if $4random=1 then  $pos4=random (84,136,1)
if $4random=2 then  $pos4=random (136,200,1)
if $4random=3 then  $pos4=random(200,384,1)
if $4random=4 then  $pos4=random (384,424,1)
if $4random=5 then  $pos4=random (424,512,1)
if $4random=6 then  $pos4=random (512,520,1)
if $4random=7 then  $pos4=random (520,600,1)
$4=$pos4
$12=0
endif


if $13=600 Then
$5random=random (0,7,1)
if $5random=0 then  $pos5=random (0,84,1)
if $5random=1 then  $pos5=random (84,136,1)
if $5random=2 then  $pos5=random (136,200,1)
if $5random=3 then  $pos5=random(200,384,1)
if $5random=4 then  $pos5=random (384,424,1)
if $5random=5 then  $pos5=random (424,512,1)
if $5random=6 then  $pos5=random (512,520,1)
if $5random=7 then  $pos5=random (520,600,1)
$5=$pos5
$13=0
endif


if $14=600 Then
$6random=random (0,7,1)
if $6random=0 then  $pos6=random (0,84,1)
if $6random=1 then  $pos6=random (84,136,1)
if $6random=2 then  $pos6=random (136,200,1)
if $6random=3 then  $pos6=random(200,384,1)
if $6random=4 then  $pos6=random (384,424,1)
if $6random=5 then  $pos6=random (424,512,1)
if $6random=6 then  $pos6=random (512,520,1)
if $6random=7 then  $pos6=random (520,600,1)
$6=$pos6
$14=0
endif

if $15=600 Then
$7random=random (0,7,1)
if $7random=0 then  $pos7=random (0,84,1)
if $7random=1 then  $pos7=random (84,136,1)
if $7random=2 then  $pos7=random (136,200,1)
if $7random=3 then  $pos7=random(200,384,1)
if $7random=4 then  $pos7=random (384,424,1)
if $7random=5 then  $pos7=random (424,512,1)
if $7random=6 then  $pos7=random (512,520,1)
if $7random=7 then  $pos7=random (520,600,1)
$7=$pos7
$15=0
endif


if $16=600 then
$8random=random (0,7,1)
if $8random=0 then  $pos8=random (0,84,1)
if $8random=1 then  $pos8=random (84,136,1)
if $8random=2 then  $pos8=random (136,200,1)
if $8random=3 then  $pos8=random(200,384,1)
if $8random=4 then  $pos8=random (384,424,1)
if $8random=5 then  $pos8=random (424,512,1)
if $8random=6 then  $pos8=random (512,520,1)
if $8random=7 then  $pos8=random (520,600,1)
$8=$pos8
$16=0
endif

sleep (15)
WEnd

func right ()
    $left=$left+10
guictrlsetpos ($pic1,$left, $top, $menormal, $menormal)
endfunc
func left ()
    $left=$left-10
guictrlsetpos ($pic1,$left, $top, $menormal, $menormal)
endfunc

the problem is i cant get it to work when the boxes hit the char then somethink need to happends

i tryed

if $pic1=$pic2 or $pic3 or $pic4 or $pic5 or $pic6 or $pic7 or $pic8 or $pic9 then
;do somethink 
endif

that dosent work... ?

some one have a solution i will be really happy if they could show me?

Link to comment
Share on other sites

Wow O_O thats quite a messy code, hard to understand it.

Anyhow, this is what I suggest:

If you have a box 50 pixels wide and 50 pixels high, and you know its starting position. Then you can use

If $MousePosX > $BoxPosX[1] And $MousePosX < $BoxPosX[1] + 50 And $MousePosY > $BoxPosY[1] And $MousePosY < $BoxPosY[1] + 50 Then
{your code}
Endif

BosPosX is where you put your box (starting coordinates, left coordinates) BoxPosX+50 are the mostright coordinates of the box. Same with the Y axis.

Link to comment
Share on other sites

okay some of it works

i tryed like you said

my $left is the left of the char

$top is the top of the char

and then there is a lot of cords to the other boxes (in this ex. i used the first box where left =$1 and top=$9(and my box is 44*44 and 55*55 and 33*33) )

so i tryed like this

if $left > $1 and $left < $1+44 and $top >$9 and $top < $9+44 then
sleep (5000)
endif

if $left > $2 and $left < $2+33 and $top >$10 and $top < $10+33 then
sleep (5000)
endif

if $left > $3 and $left < $3+44 and $top >$11 and $top < $11+44 then
sleep (5000)
endif

if $left > $4 and $left < $4+44 and $top >$12 and $top < $12+44 then
sleep (5000)
endif

if $left > $5 and $left < $5+55 and $top >$13 and $top < $13+55 then
sleep (5000)
endif
if $left > $6 and $left < $6+44 and $top >$14 and $top < $14+44 then
sleep (5000)
endif
if $left > $7 and $left < $7+55 and $top >$15 and $top < $15+55 then
sleep (5000)
endif
if $left > $8 and $left < $8+33 and $top >$16 and $top < $16+33 then
sleep (5000)
endif

but the problem is when i hit the boxes (when i go into one of them from the left og right) then nothing happends why ?

Link to comment
Share on other sites

okay some of it works

i tryed like you said

my $left is the left of the char

$top is the top of the char

and then there is a lot of cords to the other boxes (in this ex. i used the first box where left =$1 and top=$9(and my box is 44*44 and 55*55 and 33*33) )

so i tryed like this

if $left > $1 and $left < $1+44 and $top >$9 and $top < $9+44 then
sleep (5000)
endif

if $left > $2 and $left < $2+33 and $top >$10 and $top < $10+33 then
sleep (5000)
endif

if $left > $3 and $left < $3+44 and $top >$11 and $top < $11+44 then
sleep (5000)
endif

if $left > $4 and $left < $4+44 and $top >$12 and $top < $12+44 then
sleep (5000)
endif

if $left > $5 and $left < $5+55 and $top >$13 and $top < $13+55 then
sleep (5000)
endif
if $left > $6 and $left < $6+44 and $top >$14 and $top < $14+44 then
sleep (5000)
endif
if $left > $7 and $left < $7+55 and $top >$15 and $top < $15+55 then
sleep (5000)
endif
if $left > $8 and $left < $8+33 and $top >$16 and $top < $16+33 then
sleep (5000)
endif

but the problem is when i hit the boxes (when i go into one of them from the left og right) then nothing happends why ?

Try tweaking the values a little bit, I used something like that in my mini game too and I had to adjust the values. For example, for a box 40 pixels wide I had to use 40+5.

Edited by Qousio
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...