April 23, 2024, 11:18:18 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


BubbleWrap Fetish

Started by GWS, September 25, 2011, 12:20:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

September 25, 2011, 12:20:13 PM Last Edit: October 05, 2011, 12:30:13 PM by GWS
Hi folks,

Feed your fetish - pop away like mad, just click on them..  ;D

You've got 20 seconds to see how many you can zap.

The hard part of this program, was laying out a large number of bubble sprites, and knowing which one has been popped.  Then move it out of the way and replace it with a popped bubble sprite.

I've included the .exe  file in the .zip ;D

best wishes, :)

Graham

Tomorrow may be too late ..

pistol350

Hello Graham,
On my PC with Vista,
When I click on a bubble, it does not pop,
but its right side neighbour does.

I guess there is something wrong with the bubbles' location.
Regards,

Peter B.

GWS

Hi Pete,

It's nice to get a comment, even if it's a problem ..  ;D

I've no idea what that might be - it's all working fine for me.  I wonder if anyone else has had the same effect ..

I've attached a screengrab image - do you get the same bubble layout?

The only other thing that comes to mind is DX7 ..  ::)
Are you able to run the direct X example programs under Vista?

I don't have a Vista machine so I can't check it out. 

Sorry I'm not a lot of help ..

best wishes, :)

Graham
Tomorrow may be too late ..

W4GNS

  I'm using XP Pro SP3 and the bubble I click on never pops and not even it's neighbor, looks like no less than 3 bubbles away and at random locations.
Regards Gary

Quote from: GWS on October 03, 2011, 11:35:41 AM
Hi Pete,

I.  I wonder if anyone else has had the same effect ..



best wishes, :)

Graham
Gary Scott-W4GNS

GWS

Hello W4GNS ..  :) .. not a radio amateur by any chance?

If so, my GlobalView program puts you somewhere in the SE - maybe Atlanta ..

It gets worse .. it was a tricky bit to find which bubble had been popped, but I thought I'd solved it - obviously not.

At the moment, short of re-working the sprite hit-testing procedure, I haven't a clue what's going on.

It works fine for me with the existing method, so clearly there's no point in my investigating that - there's no error for me to locate this end ..  ::)

Obviously it needs a more robust method.  I'll have to try something else ..

Oh well! .. can't win them all I suppose. :)

One other thing you could try, is whether my 'Balloons' program works OK on your machines - that has a sprite collision process which is similar - just looking for clues ..  :P

Best wishes, :)

Graham



Tomorrow may be too late ..

W4GNS

 I have had the GNS for about 10 years, the person that had the call before me was from GA. QRZ and Hamcall has me correctly listed as being in Virginia.

I made a donation for CB a couple days ago, so I will look through your code when I get a chance and see if I can discover why there  are issues on my machine.

Presently, I'm giving IWbasic the once over, but I'm not happy with the licensing, so I expect to not look too closely at it.

Regards Gary W4GNS
dit dit

Quote from: GWS on October 03, 2011, 12:39:31 PM
Hello W4GNS ..  :) .. not a radio amateur by any chance?

If so, my GlobalView program puts you somewhere in the SE - maybe Atlanta ..



Graham




Gary Scott-W4GNS

GWS

Glad to see you here Gary ..  :)

My program wasn't too far off the original QTH then .. :)

I'm G4EVW from central UK.

I'm sure you'll like CB - it's very nice to use.  Not as many features as IWB of course .. it's a much smaller program, and never did get the upgrades I'd hoped for.

It's still a very useful development system though, as you will see if you take a look at all the many varied programs posted on the forum.

For the bubbles program, it looks as if I've got the collision detection wrong .. it worked OK for me, so I wonder now, did it work for anyone else, or was it a complete failure.

Not to worry, I'll sort it out eventually ..

all the best, :)

Graham
Tomorrow may be too late ..

LarryMc

Quote from: W4GNS on October 03, 2011, 02:09:13 PM

Presently, I'm giving IWbasic the once over, but I'm not happy with the licensing, so I expect to not look too closely at it.

Regards Gary W4GNS
dit dit


Curious, what part of IWB licensing do you not like?
LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

Graham:
Here with me the ballons are popping to the right of my cursor position. Sometimes the next ballon to the right, and sometimes another. But always to the right of the cursor position. Been scratcing my head all evening here, but so far whithout beeing able to figure out what's going on....

W4GNS:
Hi Gary, my callsign is LA2PJ. Located on a small remote island, on the west coast of Norway. Creative basic is a very powerfull tool. It is very useful for making ham utilities.

73's

Egil
Support Amateur Radio  -  Have a ham  for dinner!

W4GNS

 Hello Larry
The short answer is "You may use this product on a single computer" quoted from the manual.

I'm a hobbyist and use programs on all my machines, which normally consist of just 2, a desktop, and a laptop. And when I upgrade, I plan to migrate software to the new machine. So with all respect I don't like 1 computer licenses.

Quote from: LarryMc on October 03, 2011, 02:40:04 PM
Quote from: W4GNS on October 03, 2011, 02:09:13 PM



Curious, what part of IWB licensing do you not like?
LarryMc
Gary Scott-W4GNS

GWS

Thanks for looking Egil .. so far it beats me what's going on  ::)

The logic seems OK, and everything works to plan here in XP SP2 Home Edition.

It's probably something simple, but I haven't spotted it yet ..  ??? .. a bit difficult for me, since apparently on my machine, there's no problem - so I don't know what I'm looking for ..  ::)

best wishes, :)

Graham
Tomorrow may be too late ..

Egil

Think I have found at least part of the problem, Graham.
You state that the program is designed for 1024 x768 screen size, and then use the @MAXIMIZED flag when defining the window:


' designed for 1024 x 768 screen size ..
sW = 1024 : sH = 768

window w,0,0,sW,sH,@NOAUTODRAW|@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"BubbleWrap",mainwindow


When deleting the @MAXIMIZED flag, part of the problem has dissapeared, but there is still something wrong at the bottom of the window.
Haven't got more time for this today, I have to reach a ferry, but will try to experiment with the program "client area" when I return home tomorrow.

Regards,
Egil
Support Amateur Radio  -  Have a ham  for dinner!

GWS

Well spotted Egil ..  ;D .. that one slipped through ..

I've changed the prog to correct the rectangle position around the GO button as well ..

Whether that's corrected the strange DX effects I don't know - it's working OK here ..


' GWS September 2011
' Bubble Wrap - Creative Basic Code

def w:window
def i,j,n,bu[250],run:int
def sW,sH,bp[4],p,bdown,pop:int
def mx,my,incy:int
def xstart,ystart,xinc,yinc:int
def hit,varW,varH:int
def posx,posy:int
def bmax,x,bx[250],by[250]:int
def px[250],py[250],ps[250]:int
def secs,popped,goflag,restart:int
def a$,b$,c$:string

declare "WINMM",mciSendStringA(Command:string,Ret:string,RetLen:int,CallBack:int),int
declare Rn(low:INT,high:INT)

autodefine "off"

' designed for 1024 x 768 screen size ..
sW = 1024 : sH = 768

window w,0,0,sW,sH,@NOAUTODRAW|@MINBOX|@MAXBOX|@SIZE,0,"BubbleWrap",mainwindow
setwindowcolor w,rgb(30,60,10)
centerwindow w

' define button controls ..
control w, "B,Exit, (sW - 70)/2, sH*0.85, 70, 30, @ctlbtnflat, 1"
setcontrolcolor w, 1, 0, rgb(120,140,220)
showwindow w,@SWHIDE,1

control w, "B,Go, (sW - 70)/4, sH*0.85, 70, 30, @ctlbtnflat, 2"
setcontrolcolor w, 2, 0, rgb(120,140,220)
showwindow w,@SWHIDE,2

control w, "B,New, 3*(sW - 70)/4, sH*0.85, 70, 30, @ctlbtnflat, 3"
setcontrolcolor w, 3, 0, rgb(120,140,220)
showwindow w,@SWHIDE,3

' two text boxes for game progress values ..
control w,"T,,sw*0.075,sH*0.85,70,45,@cteditcenter,4"
SetControlColor w,4,rgb(180,180,50),rgb(30,60,10)
control w,"T,,sw*0.85,sH*0.85,70,45,@cteditcenter,5"
SetControlColor w,5,rgb(180,180,50),rgb(30,60,10)

' create a DX screen ..
if CreateScreen(w,sW,sH) < 0
messagebox w, "Could not create DirectX screen","Error"
closewindow w
end
endif

drawmode w,@TRANSPARENT

'load a background image
If DXNEWMAP(w,getstartpath + "green.jpg",1024,768,1) = 0
MESSAGEBOX w, "Could not load the background image","Error"
CloseWindow w
END
endif
'create a blank map filled with tile#0
DXCREATEMAP w,1,1,0

launch :' initialise the game

showwindow w,@SWRESTORE,1
showwindow w,@SWRESTORE,2
showwindow w,@SWRESTORE,3

run = 1

waituntil run = 0
mciSendStringA("Close " + getstartpath + "pink.mid","",0,0)
closewindow w
END

mainwindow:
select @CLASS
  case @IDCLOSEWINDOW
    run = 0

case @IDKEYDOWN
if (@code = 0x1B) then run = 0 :' Escape key ends game

case @IDCONTROL
select @controlid
case 1 :' Exit
run = 0
case 2 :' Go button clicked
' start the game ..
goflag = 1
setfocus w
starttimer w,1000,1
EnableControl w, 2, 0 :' GO button disabled
case 3
' New game ..
secs = 20 :' Reset game countdown timer
popped = 0 :' Reset number of bubbles popped to zero
setfocus w :' take the focus away from the New control
bubbles :' reset all the bubble sprites to initial positions
' start music ..
mciSendStringA("Play " + getstartpath + "pink.mid","",0,0)
' reset the popped sprite arrays ..
for i = 1 to 249
px[i] = 0
py[i] = 0
ps[i] = 0
next i
goflag = 0 :' disable clicking until the GO button is clicked
restart = 1 :' GO button needs to be pressed to start game
EnableControl w, 2, 1 :' GO button enabled
EnableControl w, 3, 0 :' New game button disabled

endselect
case @IDMOUSEMOVE
mx = @mousex: my = @mousey
' an increment is needed to allow for the mouse being in a captioned window (20 pixels)
incy = 20*my/sH
my = my + incy

  case @IDDXUPDATE
' draw the background
DXDRAWMAP w

' display main text ..
setfont w, "Arial", 22, 700, @sfitalic
frontpen w,RGB(80,180,250)
move w, (sW-varW)/2,sH*0.04
print w, a$

' display game text ..
setfont w, "Arial", 12, 600
move w, sW*0.06,sH*0.83
print w, b$
move w, sW*0.855,sH*0.83
print w, c$

setfont w, "Arial", 26, 600, 0, 4
setfont w, "Arial", 26, 600, 0, 5
frontpen w,RGB(180,180,50)
setcontroltext w,4,ltrim$(str$(secs))
setcontroltext w,5,ltrim$(str$(popped))

' track the cursor with the point sprite ..
dxmovesprite p, mx, my
dxdrawsprite w,p

' display unpopped bubble sprites ..
for i = 1 to bmax
for j = 1 to 12
x = i + (j-1) * bmax
dxmovesprite bu[x],bx[x],by[x]
dxdrawsprite w,bu[x]
next j
next i

' check for a popped bubble ..
if (bdown = 1) & (goflag = 1) :' check game is running
hit = DXHITANY(w,p,1)
if (hit > 0)

x = DXGetSpriteData(hit,@SDUserData)

if (x > 0) :' if x = 0 it is an already popped bubble
pop = Rn(1,3) :' pick one of the three popped images ..
' save the popped sprite co-ords and image number
px[x] = bx[x]: py[x] = by[x]: ps[x] = pop
PLAYWAVE getstartpath + "pop.wav",@SNDASYNC
bdown = 0
bx[x] = -bx[x] :' remove the popped sprite off screen left
popped = popped + 1
endif
endif
endif

' draw the popped sprites ..
for i = 1 to 240
pop = ps[i]
if (pop > 0)
dxmovesprite bp[pop],px[i],py[i]
dxdrawsprite w,bp[pop]
endif
next i

' highlight the GO button if the game is waiting to be started ..
if (goflag = 0) & (restart = 1)
rect w,sW*0.234,sH*0.88,72,33,rgb(255,0,0)
endif

DXFLIP w

' check for the point sprite contacting a bubble when mouse clicked ..
case @IDLBUTTONDN
if (goflag = 1) then bdown = 1
case @IDLBUTTONUP
bdown = 0

case @idtimer
select @code
case 1
' countdown timer ..
secs = secs - 1
if (secs = 0) :' game over
stoptimer w,1
goflag = 0 :' no more clicks allowed
restart = 0 :' game needs to be restarted
EnableControl w, 2, 0 :' GO button disabled
EnableControl w, 3, 1 :' enable New game button
' stop the music ..
mciSendStringA("Close " + getstartpath + "pink.mid","",0,0)
endif
endselect
endselect
RETURN


sub launch
' launch a new game ..
' load the unpopped sprite ..
for i = 1 to 240
bu[i] = dxsprite(w,getstartpath+"b20.bmp",50,50,1,rgb(0,0,0))
DXSetSpriteData bu[i],@SDBLTTYPE,@BLTTRANS
next i
' load the popped sprites ..
bp[1] = dxsprite(w,getstartpath+"b1.bmp",50,50,1,rgb(0,0,0))
DXSetSpriteData bp[1],@SDBLTTYPE,@BLTTRANS

bp[2] = dxsprite(w,getstartpath+"b2.bmp",50,50,1,rgb(0,0,0))
DXSetSpriteData bp[2],@SDBLTTYPE,@BLTTRANS

bp[3] = dxsprite(w,getstartpath+"b3.bmp",50,50,1,rgb(0,0,0))
DXSetSpriteData bp[3],@SDBLTTYPE,@BLTTRANS

' load the point sprite ..
p = dxsprite(w,getstartpath+"point.bmp",1,1,1)

' setup the bubble wrap using the unpopped sprite ..
xstart = 45: ystart = 80
xinc = 45: yinc = 45
bmax = 20 :' number of bubbles in each row across the screen
goflag = 0 :' game not runnug until GO button is clicked
restart = 1 :' game needs to be started using the GO button

' setup main text ..
setfont w, "Arial", 22, 700, @sfitalic
frontpen w,RGB(80,180,250)
a$ = "Pop the Bubbles"
gettextsize w, a$, varW, varH

' setup game text ..
b$ = "Seconds Left"
secs = 20 :' allow 20 seconds for each game

c$ = "Popped"
popped = 0 :' start with no bubbles popped

bubbles :' initialise a new set of bubbles

EnableControl w, 3, 0 :' disable the New game button

' start music ..
mciSendStringA("Play " + getstartpath + "pink.mid","",0,0)

return

sub bubbles
def x:int

' draw new bubblewrap ..
for i = 1 to bmax
for j = 1 to 12
posx = xstart + (i-1)*xinc +(j%2)*xinc/2
posy = ystart + (j-1)*yinc
x = i + (j-1) * bmax :' bubble number starting from 1 at left of top row
DXSetSpriteData bu[x],@SDUserData,x
' save the bubble co-ords ..
bx[x] = posx: by[x] = posy
next j
next i
return

sub Rn(low,high)
' generates a random number between Low and High ..
n = int((high - low + 1) * rnd(1.0) + low)
return n



all the best, :)

Graham
Tomorrow may be too late ..

LarryMc

Graham,
That fixed the bubble pop position on my computer(I was having the same problem as the others).

The only thing I see wrong right now is when I start the program there is a red rectangle that covers part of the go button.
It looks like a frame for the button that is dsiplaced 10px to the left and up.

As soon as I hit the go button the rectangle disappears and all is well in the world.

LarryMc

BTW, good catch Egil.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

Was planning to go to Trondheim today, but the express ferry is now cancelled for the rest of the day, due to engine problems..... But that means I am back to pop bubbles. ;D

The only thing that remains now is to move the GO-button highlighting to the correct position.
By the way, what version of CB did you use to make the exe-file?
Using version 1.153 doesn't work here with me. It runs fine from whithin the CB IDE though.

I enclose an icon to use with the exe, so everyone can see who made the software.... ;)

Egil
Support Amateur Radio  -  Have a ham  for dinner!

GWS

Hi Egil,

Sorry you missed your boat ..  ;D

While you were away, I posted a fix (maybe) for the red rectangle - but Larry reckons it still isn't a very good fit ..  :(

I'm still using the free Version 1.0 myself - it's the most well-tested and reliable.

The more recent versions were really only 'bleeding edge' versions and had not been thoroughly tested in the field.

I'll have a try with the icon ..  ;D

Have you taken a peek at my radio in the General/Off-Topic section?

best wishes, :)

Graham
Tomorrow may be too late ..

Egil

I didn't miss the boat. When they started the engines, it sounded like they had problems with an engine bearing. The engined was stopped imediately. And we were told that the trip was cancelled....
You are probably right about the bleeding edge versions. Installed version 1.01 (the first version I got), and no problems making the exe now. But to finish some of the  work I have started here, I have to reinstall the newer version, because I use the serial component for the remote control software I am working on for my FT-817ND transceiver.

Regards,
Egil
Support Amateur Radio  -  Have a ham  for dinner!

GWS

Hi folks,

Thanks to Egil for locating the likely error in my code. ;D

I've updated the program - got rid of the red rectangle that highlighted the GO button, and substituted colouring the button instead.

I've also used the Pooh Bear icon that Egil kindly provided ..  ;D

The updated code is now attached to the first post above.

I would be interested to know if that has resolved the display issues ..

best wishes, :)

Graham

Tomorrow may be too late ..