forums

TNT Basic Forums > Bugs!
bug
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-30-2006 05:20

Posted by:
spolvid

Find more posts by spolvid

I have a game that I'm working on and a menu when it starts up which looks like this.

int buttonhit
new button 0,240,200,002,001,000
new button 1,240,240,005,004,003

Later I have this.

buttonhit = poll button click

And then this.

if buttonhit=1

(other stuff)

However, when I run it, it switches to TNT Basic for a little bit, and then goes back to Hieroglyph.

When I delete if buttonhit=1 and all the stuff after it, it works fine.

I think this may be a bug, but it may be me not geting it. Help?

03-31-2006 17:54

Posted by:
spolvid

Find more posts by spolvid

Hello?

Is anyone there?

03-31-2006 18:27

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Yup...

I think you'll find the problem is the "(other stuff)"... If you could post the remainder of the code I'll take a look at it. ButtonHit is not going to crash TNT.

Danny (nods)

03-31-2006 21:25

Posted by:
spolvid

Find more posts by spolvid

if buttonhit=1
repeat
draw picture 134
draw frame
draw picture 135
draw frame
until mouse button

The two images are to create an animation effect.

03-31-2006 22:21

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Got it...

Your problem is that you are detecting the mouse down event of the button click inside your loop. Try this:

if buttonhit=1
repeat
until not mouse button 'wait for user to release the button!

repeat
draw picture 134
draw frame
draw picture 135
draw frame
until mouse button

Give that a go and get back if it still doesn't work...

Danny (nods)

04-01-2006 00:29

Posted by:
spolvid

Find more posts by spolvid

No good. Any other ideas?

04-01-2006 15:47

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

the problem is we don't know what you're doing exactly, so it would probably help if you could build a small project that demonstrates the bug, without any other unrelated stuff, so we could look quickly at it and see what's wrong

04-01-2006 20:23

Posted by:
spolvid

Find more posts by spolvid

I don't know what the problem is, so I can't build anything to demonstate it, so here's the entire code, with allnodcoms's suggestion.

window mode 640,480
music loop on
load images 128
load music 128
play music
int buttonhit = 3
new button 0,240,200,002,001,000
new button 1,240,240,005,004,003
repeat
draw picture 134
draw frame
draw picture 135
draw frame
buttonhit = poll button click
until buttonhit>-1
if buttonhit=1
repeat
until mouse button
repeat
draw picture 134
draw frame
draw picture 135
draw frame
until mouse button

Hope this helps!

04-02-2006 15:39

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

you forgot a 'end if'

it's weird, when i ran the code you posted, it didn't work. i added 'end if' and it worked. seems like TNT failed to notice a 'end if' was missing! (a least for me)

04-03-2006 04:13

Posted by:
spolvid

Find more posts by spolvid

Hmmmm...

Now at least TNT Basic starts up, but when I click on button 1, it's suposed to go into another loop, but TNT BAsic just quits.

04-03-2006 04:14

Posted by:
spolvid

Find more posts by spolvid

*supposed

04-03-2006 12:03

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

Yes you're missing one end if.

And also you need to make the loop with nothing in it repeat until not mouse button. This way your game wil not continue unless the player releases the mouse button.

04-03-2006 19:05

Posted by:
spolvid

Find more posts by spolvid

I have the end if and until not mouse button but it still won't go to the second loop.

04-03-2006 23:19

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

i tried it and it worked (only if you click on the right button of course, you specified 'if buttonhit=1' so clicking on button #0 will not work, however clicking on button #1 worked fine for me)

i ran the following code (it's the same as yours, right?)

window mode 640,480

music loop on
load music 128
play music

load images 128

int buttonhit = -1
new button 0,240,200,002,001,000
new button 1,240,240,005,004,003

repeat

draw picture 128
draw frame
draw picture 129
draw frame
buttonhit = poll button click

until buttonhit>-1

if buttonhit=1

repeat
until not mouse button

repeat
draw picture 128
draw frame
draw picture 129
draw frame
until mouse button

end if

04-04-2006 05:42

Posted by:
spolvid

Find more posts by spolvid

Yes, that is what I am doing, and it should have been if buttonhit=0 but it still doesn't work, it won't go into the second loop.

04-04-2006 05:45

Posted by:
spolvid

Find more posts by spolvid

All fixed!

I had the wrong pics desplaying.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.