Function PlayerNumberSelection()
SetScreen()
FileExplore.SetWindowStyle(0x10000000)
CreateText(1, "Select Number of Players")
SetTextSize(1, 25)
SetTextFont(1, 1)
SetTextColor(1, 250, 12, 0, 255)
TextW = GetTextTotalWidth(1)
SetTextPosition(1, 600 - TextW / 2, 20)
// text buttons
CreateText(2, "1")
SetTextFont(2, 1)
SetTextSize(2, 16)
SetTextColor(2, 255, 255, 255, 255)
SetTextPosition(2, 459, 323)
Acct_Num_Plyrs = 0
// main loop
do
DrawBox(440, 305, 490, 355, MakeColor(220, 220, 0), MakeColor(220, 220, 0), MakeColor(220, 220, 0), MakeColor(220, 220, 0), 0)
MouseX = GetPointerX()
MouseY = GetPointerY()
If GetPointerState() = 1
If MouseX > 439 and MouseX < 491 and MouseY < 304 and MouseY < 256
SetTextColor(2, 255, 0, 0, 255)
Sync()
Sleep(150)
DeletePNS()
Acct_Num_Plyrs = 1
Exit
Endif
Sync()
loop
EnterSurName()
EndFunction
Function DeletePNS()
DeleteText(1)
DeleteText(2)
EndFunction
Function PlyrAccount()
`SetScreen()
FileExplore.SetWindowStyle(0x10000000) // || 0x01000000 || 0x80000000) // (WS_VISIBLE | WS_CLIPSIBLINGS | WS_POPUP)
//LoadImage(1, "GoalBall.png")
//CreateSprite(1, 1)
//SetSpriteSize(1, 1200, 431)
//SetSpritePosition(1, 0, 370)
// load images
//LoadImage(2, "ManagerRed.png") // Manager up
//LoadImage(3, "ManagerRedDark.png") // Manager down
//LoadImage(4,"CoachRed.png") // coach up
//LoadImage(5,"CoachRedDark.png") // coach down
//LoadImage(6,"LoadSavedGameRed.png") // load saved game up
//LoadImage(7,"LoadSavedGameRedDark.png") // load saved game down
` screen title
CreateText(0,"Select Game Type")
SetTextSize(0,25)
SetTextFont(0,1)
SetTextColor(0,250,12,0,255)
TextW=GetTextTotalWidth(0)
SetTextPosition(0,600- TextW/2,20)
//---------------------------------text above manager button -----------
` every business text
CreateText(1,"Every business")
SetTextSize(1, 12)
SetTextFont(1, 1) // set font to use
SetTextColor(1,255, 255, 255, 255) // set text color
SetTextPosition(1,221,257)
` function controlled text
CreateText(2,"function controlled")
SetTextSize(2, 12)
SetTextFont(2,1) // set font to use
SetTextColor(2, 255,255, 255, 255) // set text color
SetTextPosition(2,190,282)
` by player text
CreateText(3,"by player")
SetTextSize(3, 12)
SetTextFont(3,1) // set font to use
SetTextColor(3, 255,255, 255, 255) // set text color
SetTextPosition(3,247,307)
CreateText(4, "Manager")
SetTextSize(4, 16)
SetTextFont(4, 1)
SetTextColor(4, 255, 0, 0, 255)
SetTextPosition(4, 245, 345)
`----------------------------------text above coach button
CreateText(5,"Every business")
SetTextSize(5, 12)
SetTextFont(5, 1) // set font to use
SetTextColor(5,255, 255, 255, 255) // set text color
SetTextPosition(5,824,257)
CreateText(6,"function controlled")
SetTextSize(6, 12)
SetTextFont(6,1) // set font to use
SetTextColor(6, 255,255, 255, 255) // set text color
SetTextPosition(6,796,282)
CreateText(7,"by computer")
SetTextSize(7, 12)
SetTextFont(7,1) // set font to use
SetTextColor(7, 255,255, 255, 255) // set text color
SetTextPosition(7,842,307)
CreateText(8, "Coach")
SetTextSize(8, 16)
SetTextFont(8, 1)
SetTextColor(8, 255, 0, 0, 255)
SetTextPosition(8, 860, 345)
`---------------------------------------------------------------------
`----------------------------------------text above Load saved game button
` load saved game text
CreateText(9,"Load saved game")
SetTextSize(9,12)
SetTextFont(9,1)
SetTextColor(9, 255,255, 255, 255)
TextW=GetTextTotalWidth(9)
SetTextPosition(9,600-TextW/2,437)
CreateText(10,"Load saved game")
SetTextSize(10,16)
SetTextFont(10,1)
SetTextColor(10, 255,0, 0, 255)
SetTextPosition(10,505,467)
// PlyrAcct main loop
do
MouseX = GetPointerX()
MouseY = GetPointerY()
print( GameType.length)
DrawBox(1,1,1198,798,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // screen outer frame
//DrawBox(395,45,800,550,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // title frame
DrawBox(172,341,402,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Manager box
DrawBox(775,341,1005,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Coach box
DrawBox(485,463,715,486,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Load saved game box
// manager text 10
if GetPointerState() = 1
if MouseX > 171 and MouseX <403 and MouseY > 340 and MouseY < 365
SetTextColor(4, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 775 and MouseX < 1005 and MouseY > 340 and MouseY < 365
SetTextColor(8, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 485 and MouseX < 715 and MouseY > 463 and MouseY < 486
SetTextColor(10, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
Sync()
loop
PlayerNumberSelection()
EndFunction
function DeleteTextObjects()
for i = 0 to 10
DeleteText(i)
next i
endfunction
SetWindowSize(1024,768,0)
SetVirtualResolution(1024,768)
UseNewDefaultFonts(1)
while not GetRawKeyPressed(27)
clicked = Button(400,300,600,400, 255,64,64, "Test Button")
if clicked = 1
print("Clicked!")
endif
print(ScreenFPS())
sync()
endwhile
function Button(startX as float, startY as float, endX as float, endY as float, colorR, colorG, colorB, text as string)
// using a temp sprite for drawing the box
imgId = CreateImageColor(255,255,255,255)
sprId = CreateSprite(imgId)
SetSpriteColor(sprId, colorR, colorG, colorB, 255)
SetSpritePosition(sprId, startX, startY)
SetSpriteSize(sprId, endX - startX, endY - startY)
textId = CreateText(text)
SetTextSize(textId, 32)
SetTextAlignment(textId, 1)
SetTextPosition(textId, startX + (endX - startX) * 0.5, startY + (endY - startY) * 0.5 - GetTextTotalHeight(textId) * 0.5)
mx# = GetPointerX()
my# = GetPointerY()
result = 0
if mx# >= startX and mx# <= endX and my# >= startY and my# <= endY
// add mouse-over changes here, like color change using SetSpriteColor/SetTextColor
if GetPointerState() = 1
// add clicked changes here
result = 1
endif
endif
DrawSprite(sprId)
DrawText(textId)
DeleteImage(imgId)
DeleteSprite(sprId)
DeleteText(textId)
endfunction result
would highly recommend turning your button code into a reusable function to avoid this kind of mistake. You could probably make it an immediate mode sort of function, like this:
// Player Account Include File
`#Include "SelectLeague.agc"
Function PlyrAccount()
`SetScreen()
FileExplore.SetWindowStyle(0x10000000) // || 0x01000000 || 0x80000000) // (WS_VISIBLE | WS_CLIPSIBLINGS | WS_POPUP)
` screen title
CreateText(0,"Select Game Type")
SetTextSize(0,25)
SetTextFont(0,1)
SetTextColor(0,250,12,0,255)
TextW=GetTextTotalWidth(0)
SetTextPosition(0,600- TextW/2,20)
//---------------------------------text above manager button -----------
` every business text
CreateText(1,"Every business")
SetTextSize(1, 12)
SetTextFont(1, 1) // set font to use
SetTextColor(1,255, 255, 255, 255) // set text color
SetTextPosition(1,221,257)
` function controlled text
CreateText(2,"function controlled")
SetTextSize(2, 12)
SetTextFont(2,1) // set font to use
SetTextColor(2, 255,255, 255, 255) // set text color
SetTextPosition(2,190,282)
` by player text
CreateText(3,"by player")
SetTextSize(3, 12)
SetTextFont(3,1) // set font to use
SetTextColor(3, 255,255, 255, 255) // set text color
SetTextPosition(3,247,307)
CreateText(4, "Manager")
SetTextSize(4, 16)
SetTextFont(4, 1)
SetTextColor(4, 255, 0, 0, 255)
SetTextPosition(4, 245, 345)
`----------------------------------text above coach button
CreateText(5,"Every business")
SetTextSize(5, 12)
SetTextFont(5, 1) // set font to use
SetTextColor(5,255, 255, 255, 255) // set text color
SetTextPosition(5,824,257)
CreateText(6,"function controlled")
SetTextSize(6, 12)
SetTextFont(6,1) // set font to use
SetTextColor(6, 255,255, 255, 255) // set text color
SetTextPosition(6,796,282)
CreateText(7,"by computer")
SetTextSize(7, 12)
SetTextFont(7,1) // set font to use
SetTextColor(7, 255,255, 255, 255) // set text color
SetTextPosition(7,842,307)
CreateText(8, "Coach")
SetTextSize(8, 16)
SetTextFont(8, 1)
SetTextColor(8, 255, 0, 0, 255)
SetTextPosition(8, 860, 345)
`----------------------------------------text above Load saved game button
` load saved game text
CreateText(9,"Load saved game")
SetTextSize(9,12)
SetTextFont(9,1)
SetTextColor(9, 255,255, 255, 255)
TextW=GetTextTotalWidth(9)
SetTextPosition(9,600-TextW/2,437)
CreateText(10,"Load saved game")
SetTextSize(10,16)
SetTextFont(10,1)
SetTextColor(10, 255,0, 0, 255)
SetTextPosition(10,505,467)
// PlyrAcct main loop
do
MouseX = GetPointerX()
MouseY = GetPointerY()
print( GameType.length)
DrawBox(1,1,1198,798,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // screen outer frame
//DrawBox(395,45,800,550,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // title frame
DrawBox(172,341,402,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Manager box
DrawBox(775,341,1005,364,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Coach box
DrawBox(485,463,715,486,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // Load saved game box
// manager text 10
if GetPointerState() = 1
if MouseX > 171 and MouseX <403 and MouseY > 340 and MouseY < 365
SetTextColor(4, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 775 and MouseX < 1005 and MouseY > 340 and MouseY < 365
SetTextColor(8, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
if GetPointerState() = 1
if MouseX > 485 and MouseX < 715 and MouseY > 463 and MouseY < 486
SetTextColor(10, 250, 250, 250, 255)
Sync()
Sleep(150)
DeleteTextObjects()
Exit
endif
endif
Sync()
loop
PlayerNumberSelection()
EndFunction
function DeleteTextObjects()
for i = 0 to 10
DeleteText(i)
next i
endfunction
// NUMBER OF PLAYERS SELECTION SCREEN FUNCTION-----------------------------------------
Function PlayerNumberSelection() // player number selection function
SetScreen()
WinW = GetWindowWidth()
WinH = GetWindowHeight()
VwinW = GetVirtualWidth()
VwinH = GetVirtualHeight()
CreateText(1, "Select number of players") // create the screen title text
SetTextSize(1, 25) // set text size
SetTextFont(1, 1)
SetTextColor(1, 250, 12, 0, 255) // set text color
SetTextFont(1, 1)
TextW = GetTextTotalWidth(1)
SetTextPosition(1, 600-TextW/2,20)
// screen outer frame
Global LeftFramX = 1
Global RightFramX = 1198
Global TopFramY = 1
Global BottomFramY = 798
// menu frame
Global LeftMenuFramX = 490
Global RightMenuFramX = 760
Global TopMenuFramY = 292
Global BottomMenuFramY = 430
CreateText(2, "1")
SetTextFont(2, 1)
SetTextSize(2, 16)
SetTextColor(2, 255, 255, 255, 255)
SetTextPosition(2, 459, 323)
//AddVirtualButton(1, 495, 330, 50) // button 1
//SetVirtualButtonSize(1,50,50)
//SetVirtualButtonImageUp(1, 2)
CreateText(3, "2")
SetTextFont(3, 1)
SetTextSize(3, 16)
SetTextColor(3, 255, 255, 255, 255)
SetTextPosition(3, 527, 323)
Acct_Num_Plyrs = 0
// main loop
Repeat
print( GameType.length)
DrawBox(LeftFramX,TopFramY,RightFramX,BottomFramY,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // screen outer frame
DrawBox(420,292,760,430,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // small menu frame
DrawBox(440,305,490,355,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // 1 frame
DrawBox(510,305,560,355,MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),MakeColor(220,220,0),0) // 2 frame
// Print("Game Type : "+GameType$)
MouseX = GetPointerX()
MouseY = GetPointerY()
print(MouseX)
print(MouseY)
if MouseX < 439 and MouseX < 491 and MouseY < 304 and MouseY < 356
if GetPointerState() = 1
SetTextColor(2, 250, 250, 250, 255)
Sync()
Sleep(150)
DeletePNS()
Acct_Num_Plyrs = 1
Exit
Endif
Endif
Sync()
Until Acct_Num_Plyrs > 0 // end loop
EnterSurName()
EndFunction
Function DeletePNS()
for t = 1 to 3
DeleteText(t)
next t
EndFunction
I corrected the MouseY coordinate code and it still doesn't work
nd it still didn't work? Sorry, just making sure I'm on the same page here.
if MouseX < 439 and MouseX < 491 and MouseY < 304 and MouseY < 356
if MouseX > 439 and MouseX < 491 and MouseY > 304 and MouseY < 356