[15 May 2006] Creating Menu and reacting on action

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
GMKai
Posts: 160
Joined: Mon Feb 15, 2010 10:58 am

[15 May 2006] Creating Menu and reacting on action

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 15 May 2006 08:06:28 +0200

Code: Select all

Function p_MakeMainMenu()
    ShowPointer()
    evtmatch =  {OnMouseUp = p_MenuFunc }
    MakeButton(1,#SimpleButton,#Center,100,100,100,evtmatch)
    Box(#Center,100,100,100,#Blue)
    MakeButton(2,#SimpleButton,#Center,200,100,100,evtmatch)
    Box(#Center,200,100,100,#Blue)
    MakeButton(3,#SimpleButton,#Center,300,100,100,evtmatch)
    Box(#Center,300,100,100,#Blue)
    MakeButton(4,#SimpleButton,#Center,400,100,100,evtmatch)
    Box(#Center,400,100,100,#Blue)

    WaitEvent()
EndFunction

Function p_MenuFunc(msg)
    HidePointer()
    Switch msg.id
    Case "1":
         DebugPrint("Clicked1")
         p_Game()
    Case 2:
         p_Settings()
    Case 3:
         p_Score()
    Case 4:
         p_Exit()
    EndSwitch
EndFunction

p_MakeMainMenu()
When clicking a Button nothing happens. What is missing in there?
User avatar
airsoftsoftwair
Posts: 5914
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[15 May 2006] Re: Creating Menu and reacting on action

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 15 May 2006 18:43:46 +0200

Code: Select all

Function p_MakeMainMenu()
   ShowPointer()
   evtmatch =  {OnMouseUp = p_MenuFunc }
   MakeButton(1,#SimpleButton,#Center,100,100,100,evtmatch)
   Box(#Center,100,100,100,#Blue)
   MakeButton(2,#SimpleButton,#Center,200,100,100,evtmatch)
   Box(#Center,200,100,100,#Blue)
   MakeButton(3,#SimpleButton,#Center,300,100,100,evtmatch)
   Box(#Center,300,100,100,#Blue)
   MakeButton(4,#SimpleButton,#Center,400,100,100,evtmatch)
   Box(#Center,400,100,100,#Blue)

   WaitEvent()
EndFunction

Function p_MenuFunc(msg)
   HidePointer()
   Switch msg.id
   Case "1":
        DebugPrint("Clicked1")
        p_Game()
   Case 2:
        p_Settings()
   Case 3:
        p_Score()
   Case 4:
        p_Exit()
   EndSwitch
EndFunction

p_MakeMainMenu()
When clicking a Button nothing happens. What is missing in there?
You always have to use WaitEvent() in an endless loop, e.g.

Code: Select all

Repeat
   WaitEvent
Forever
GMKai
Posts: 160
Joined: Mon Feb 15, 2010 10:58 am

[15 May 2006] Re: Creating Menu and reacting on action

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 15 May 2006 21:57:20 +0200

Code: Select all

Repeat
   WaitEvent
Forever
didn't do the trick. it seems as if the function isn't called at all as currently removed Print-Functions don't display anything.

have a look:

Code: Select all

Function p_MenuFunc(msg)
    Switch msg.id
    Case 1:
         p_Game()
    Case 2:
         p_Settings()
    Case 3:
         p_Score()
    Case 4:
         p_Exit()
    EndSwitch
EndFunction

Function p_MakeMainMenu()
    ShowPointer()
    evtmatch =  { OnMouseUp = p_MenuFunc, OnMouseOver = p_MenuFunc, OnRightMouseUp = p_MenuFunc }
    MakeButton(1,#SimpleButton,#Center, 50,99,99,evtmatch)
                           Box(#Center, 50,100,100,#Blue)
    MakeButton(2,#SimpleButton,#Center,150,99,99,evtmatch)
                           Box(#Center,150,100,100,#Blue)
    MakeButton(3,#SimpleButton,#Center,250,99,99,evtmatch)
                           Box(#Center,250,100,100,#Blue)
    MakeButton(4,#SimpleButton,#Center,350,99,99,evtmatch)
                           Box(#Center,350,100,100,#Blue)
    Repeat
       WaitEvent()
    Forever
EndFunction

p_MakeMainMenu()
User avatar
airsoftsoftwair
Posts: 5914
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[15 May 2006] Re: Creating Menu and reacting on action

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 15 May 2006 22:11:58 +0200

Code: Select all

Repeat
  WaitEvent
Forever
didn't do the trick. it seems as if the function isn't called at all as currently removed Print-Functions don't display anything.
Hmmm. I cannot test the code currently. Does it help if you do not use #CENTER in MakeButton()? I don't have the source code here, so I cannot look up whether MakeButton() handles #CENTER correctly.
GMKai
Posts: 160
Joined: Mon Feb 15, 2010 10:58 am

[16 May 2006] Re: Creating Menu and reacting on action

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 16 May 2006 18:40:11 +0200

Yeah, that did the trick. But a subfunction that worked before adding the menu with the buttons stops working. Program does not succesfully return from this function. Here it is:

Code: Select all

Function p_CreateEnemy()
    if enemytabvar < 50
        enemytab[enemytabvar][0]=enemyid
        enemytab[enemytabvar][1]=rnd(RBorder-GetAttribute(#Sprite,enemyid,#ATTRWIDTH))
        enemytab[enemytabvar][2]=0
        enemytab[enemytabvar][3]=rnd(enemymovetypes+1)
        if enemytab[enemytabvar][3]= 0
            enemytab[enemytabvar][3]= 1
        endif
        CreateSprite(enemyid,#brush,2)
        DisplaySprite(enemytab[enemytabvar][0],enemytab[enemytabvar][1],enemytab[enemytabvar][2])
     enemytabvar=add(enemytabvar,1)
        enemyid=add(enemyid,1)
        enemysonscreen = add(enemysonscreen,1)
    endif
EndFunction
User avatar
airsoftsoftwair
Posts: 5914
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[19 May 2006] Re: Creating Menu and reacting on action

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 19 May 2006 16:46:16 +0200

Hi,

I can't tell from this code snippet why the program isn't working correctly. Try to find it out on your own, or post the complete code - but I might not have the time to do a proof-read if the code is too long or confusing...
GMKai
Posts: 160
Joined: Mon Feb 15, 2010 10:58 am

[21 May 2006] Re: Creating Menu and reacting on action

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 21 May 2006 16:41:50 +0200

Here is the complete code with the used brushes. Problem seems to be in p_CollisionCheck()
User avatar
airsoftsoftwair
Posts: 5914
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[21 May 2006] Re: Creating Menu and reacting on action

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 21 May 2006 23:17:27 +0200

Oh, that's way too much code... finding the bug would take me at least 30 minutes which I don't have, so I'm afraid you have to do it on your own.
GMKai
Posts: 160
Joined: Mon Feb 15, 2010 10:58 am

[22 May 2006] Re: Creating Menu and reacting on action

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 22 May 2006 11:35:19 +0200

do I get a comment on how a non existing sprite with id 0 comes into the collision-detection in the function p_CollisionCheck()?

That sprite shouldn't be created anywhere and so there shouldn't be a check against that one.

that leads to another suggestion:

please make the id-counter for hollywood-objects like sprites and brushes begin with 0 not with 1.
User avatar
airsoftsoftwair
Posts: 5914
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[23 May 2006] Re: Creating Menu and reacting on action

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 23 May 2006 23:07:05 +0200
do I get a comment on how a non existing sprite with id 0 comes into the collision-detection in the function p_CollisionCheck()?

From a quick look at your p_CollisionCheck() function I would argue that it happens when a collision is detected, i.e. collisionfound becomes TRUE. In that case, you set shidtable[0] to 0, but you do not break out of the "For k=0 To enemytabvar" loop. Thus, in the next iteration of that loop, Collision() is called with shidtable[0] being 0 which raises an error.


On another note, I see your whole script runs with ExitOnError set to FALSE. You should really remove that because when ExitOnError is FALSE, Hollywood will never exit and you won't notice any errors that have happened.

That sprite shouldn't be created anywhere and so there shouldn't be a check against that one.

that leads to another suggestion:

please make the id-counter for hollywood-objects like sprites and brushes begin with 0 not with 1.


Some extensions to the object naming system will probably come in the next version, including the ability to give objects a string name, e.g.

LoadSprite("player", "dh0:playersprites.iff")
Locked