Author Topic: My YaBASIC Game - Green Boxcopter  (Read 17034 times)

0 Members and 1 Guest are viewing this topic.

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
My YaBASIC Game - Green Boxcopter
« on: September 20, 2006 »
well, this code uses win32yabasic, from ezboard homebrew forums...
hope you guys and lovely guys enjoy! you'll need the emulator to run the game!
one problem.... the collision in the game does not work properly! for some reason, it lets some of the helicopter pass through the blocks...
and, the boss level at the end has not been coded, but all else works.
levels 1-9 are easy!
levels 10-14 are intermediate!!!
and, levels 15-19 are extreme!
if someone thinks that the game is too hard, then i will make it easier when i code the boss and fix the collision!
Cheers,
  Â  Â Sir Johnah (Clanky)
>_<

THIS IS UPDATED!!! NEWER VERSION... NEW BITS OF CODE IMPLEMENTED!!!
Hope you enjoy

Code: [Select]
'Green Boxcopter
'Coded by Sir Johnah
'Rel-Ver: 15.09.06
'Add_Rel-Ver: 20.09.06, CCX: Slinking Shadow

'INTRODUCTION
'========
'Avoid the blocks scrolling across the screen
'or else you will crash!!! Do not hit the roof
'or the ground, or, again, you will crash.
'NB// ROOF REFERS TO THE top white bit.
'NB// GROUND REFERS TO THE bottom white bit.

'CONTROLS
'========
'D-PAD UP: Fly helicopter up
'D-PAD DOWN: Fly helicopter down
'START: Pause Game
'X (while paused): Unpause Game
'NB// NO OTHER BUTTONS ARE USED IN-GAME,
'     EXCEPT FOR MENU SELECTIONS.

'Add_Rel-Ver: 20.09.06
'=====================
'New Code:
'         Level 10-New Block Formation, Chatter Motion
'         Level 15-New Block Formation, Up/Down Motion
'         Level 20-Boss Level!!!

'Hope you enjoy the game.
'Cheers, Sir Johnah
'>_<

open window 640,512

high_score=1000

title()

'TITLE PAGE
sub title()
xp=80
yp=256
spd=3
repeat
  setdrawbuf db
  db=1-db
  setdispbuf db
  clear window
setrgb 1,100,200,100
text 245,100,"Green Boxcopter"
text 230,120,"Coded by Sir Johnah"
text 235,200,"Hit X to Play Game"
text 225,380,"{DANce tO my TRanCE}"
draw()
clear fill rect 0,475,640,500
until (peek("port1")=16384)
setup()
end sub

'SET VARIABLES
sub setup()
score=0
hi=0
stage=0
level=1
stage=0
grav=0
xp=80
yp=256
spd=5
ex1=650
ey1=int(ran(382)+100)
size1=int(ran(50)+50)
ex1s=1
ex2=960
ey2=int(ran(382)+100)
size2=int(ran(50)+50)
ex2s=2
smoke1=0
smoke2=0
smoke3=0
main()
end sub

'GAME LOOP
sub main()
label loop
  setdrawbuf db
  db=1-db
  setdispbuf db
  clear window
score=score+0.1
  if level<10 level()
  if (level>=10 and level<15) level_b10()
  if (level>=15 and level<20) level_b15()
  if level=20 boss()
  if level<20 stage=stage+0.1
'GET LEVEL VARS
  if stage>=100 then
    stage=0
    score=score+50
    spd=spd+0.25
    level=level+1
  fi
rise=0
'CALL ROUTINES
controls()
level()
chk_sum()
draw()
'GRAVITY
  if rise=0 then
    grav=grav+.69
    up=0
  fi
  if rise=1 then
    grav=0
    up=up+.69
  fi
yp=yp+grav
goto loop
end sub

sub draw()
'DRAW SMOKE
  if smoke1=0 then
    sx1=xp-30
    sy1=yp
    smoke1=1
  elsif smoke1=1 then
    sx1=sx1-spd
    setrgb 1,100,100,100
    fill circle sx1-10,sy1,5
    setrgb 1,140,140,140
    fill circle sx1-3,sy1-3,5
    setrgb 1,120,120,120
    fill circle sx1-3,sy1+3,5
    if sx1<=0 smoke1=0
    if sx1<=10 smoke2=0
  fi
  if smoke2=0 then
    sx2=xp-30
    sy2=yp
    smoke2=1
  elsif smoke2=1 then
    sx2=sx2-spd
    setrgb 1,100,100,100
    fill circle sx2-10,sy2,5
    setrgb 1,140,140,140
    fill circle sx2-3,sy2-3,5
    setrgb 1,120,120,120
    fill circle sx2-3,sy2+3,5
    if sx2<=5 smoke2=0
    if sx2<=10 smoke3=0
  fi
  if smoke3=0 then
    sx3=xp-30
    sy3=yp
    smoke3=1
  elsif smoke3=1 then
    sx3=sx3-spd
    setrgb 1,100,100,100
    fill circle sx3-10,sy3,5
    setrgb 1,140,140,140
    fill circle sx3-3,sy3-3,5
    setrgb 1,120,120,120
    fill circle sx2-3,sy3+3,5
    if sx3<=5 smoke3=0
  fi

'PLAYER HELICOPTER
setrgb 1,100,200,100
rect xp-10,yp-10,xp+10,yp+10
rect xp-10,yp-2.5,xp-35,yp+2.5
rect xp-35,yp-6,xp-42,yp+3
line xp-8,yp+10,xp-8,yp+15
line xp+8,yp+10,xp+8,yp+15
line xp-12,yp+15,xp+12,yp+15
rect xp-2,yp-10,xp+2,yp-15
rect xp+10,yp-10,xp+3,yp+3
dot xp-42,yp+3
dot xp+3,yp+3
  if rotated=0 rotate=rotate+5
  if rotated=1 rotate=rotate-5
  if rotate=30 or rotate=0 rotated=1-rotated
line xp-rotate,yp-15,xp+rotate,yp-15
'DRAW GROUND/ROOF
setrgb 1,250,250,250
fill rect 0,0,640,24
fill rect 0,417,640,512
'DRAW TABLE
clear fill rect 0,475,640,500
'SCORE
setrgb 1,100,200,100
text 10,490,"SCORE: "+str$(int(score))
  if score>high_score then
    high_score=int(score)
    hi=1
   fi
text 200,490,"HIGH SCORE: "+str$(high_score)
'DRAW LEVEL VARS
text 520,490,"LEVEL: "+str$(level)+"."+str$(int(stage/10))
setrgb 1,0,90,0
setrgb 2,0,90,0
setrgb 3,100,200,100
gtriangle 410,482 to 410+stage,482 to 410+stage,493
setrgb 2,100,200,100
gtriangle 410,482 to 410,493 to 410+stage,493
setrgb 1,0,0,0
line 420,482,420,493
line 430,482,430,493
line 440,482,440,493
line 450,482,450,493
line 460,482,460,493
line 470,482,470,493
line 480,482,480,493
line 490,482,490,493
line 500,482,500,493
setrgb 1,250,250,250
rect 410,482,510,493
dot 510,482
end sub

sub level()
'GET LEVEL BLOCKS
'FIRST BLOCK
  if ex1<=0 ex1s=1
  if ex1s=1 then
    ex1=650
    ey1=int(ran(382)+100)
    size1=int(ran(50)+50)
    ex1s=2
  elsif ex1s=2 then
    ex1=ex1-spd
  fi
'SECOND BLOCK
  if ex2<=0 ex2s=1
  if ex2s=1 then
    ex2=650
    ey2=int(ran(382)+100)
    size2=int(ran(50)+50)
    ex2s=2
  elsif ex2s=2 then
    ex2=ex2-spd
  fi
'DRAW LEVEL BLOCKS
setrgb 1,250,250,250
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
end sub

sub level_b10()
'GETTING GOOD HEY? MUST THINK TO BEAT YOU!!!
'GET LEVEL BLOCKS
'FIRST BLOCK
  if ex1<=0 ex1s=1
  if ex1s=1 then
    ex1=650
    ey1=int(ran(382)+100)
    size1=int(ran(50)+50)
    ex1s=2
  elsif ex1s=2 then
    dirx1=int(ran(2))
    if dirx1=0 drx1=spd
    if dirx1=1 drx1=-spd
    ex1=ex1-spd
    ey1=ey1-drx1
  fi
'SECOND BLOCK
  if ex2<=0 ex2s=1
  if ex2s=1 then
    ex2=650
    ey2=int(ran(382)+100)
    size2=int(ran(50)+50)
    ex2s=2
  elsif ex2s=2 then
    dirx2=int(ran(2))
    if dirx2=0 drx2=spd
    if dirx2=1 drx2=-spd
    ex2=ex2-spd
    ey2=ey2-drx2
  fi
'DRAW LEVEL BLOCKS
setrgb 1,250,250,250
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
end sub

sub level_b15()
'DAMN, SMART GUY EY'? YOU WONT BEAT ME ANYMORE
'GET LEVEL BLOCKS
'FIRST BLOCK
  if ex1<=0 ex1s=1
  if ex1s=1 then
    ex1=650
    ey1=int(ran(382)+100)
    size1=int(ran(50)+50)
    ex1s=2
    dirx1=int(ran(2))
  elsif ex1s=2 then
    if dirx1=0 drx1=spd
    if dirx1=1 drx1=-spd
    ex1=ex1-spd
    ey1=ey1-drx1
    if (ey1-size1)<=24 dirx1=1
    if (ey1+size1)>=417 dirx1=0
  fi
'SECOND BLOCK
  if ex2<=0 ex2s=1
  if ex2s=1 then
    ex2=650
    ey2=int(ran(382)+100)
    size2=int(ran(50)+50)
    ex2s=2
    dirx2=int(ran(2))
  elsif ex2s=2 then
    if dirx2=0 drx2=spd
    if dirx2=1 drx2=-spd
    ex2=ex2-spd
    ey2=ey2-drx2
    if (ey2-size2)<=24 dirx2=1
    if (ey2+size2)>=417 dirx2=0
  fi
'DRAW LEVEL BLOCKS
setrgb 1,250,250,250
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
end sub

sub boss()
'WELL....
'I CHALLENGE YOU TO A DUEL!!!
'FIGHT ME AND WIN, AND I SHALL LET YOU LIVE... BUT,
'FIGHT AND LOSE! THEN I SHALL TEAR YOU APART!!!
end sub

sub chk_sum()
'CHECK SYSTEM
  if yp<=40 crash()
  if yp>=402 crash()
'=============
'=PROBLEMS!!!=
'=============
'COLLISION FIRST BLOCK
  if (yp-15>=(ey1-size1) and yp+15<=(ey1+size1) and xp+30>=(ex1-5) and xp-42<=(ex1+5)) crash()
'COLLISION SECOND BLOCK
  if (yp-15>=(ey2-size2) and yp+15<=(ey2+size2) and xp+30>=(ex2-5) and xp-42<=(ex2+5)) crash()
end sub

sub crash()
label crash
  setdrawbuf db
  db=1-db
  setdispbuf db
smoke1=3
smoke2=3
smoke3=3
draw()
setrgb 1,200,10,10
clear fill circle xp,yp,53
fill circle xp,yp,50
setrgb 1,100,200,100
clear fill rect 190,185,415,270
rect 190,185,415,270
text 225,200,"Hit X to Restart"
text 200,220,"Hit TRIANGLE to Quit"
text 200,240,"SCORE: "+str$(int(score))
text 200,260,"LEVEL: "+str$(level)+"."+str$(int(stage/10))
setrgb 1,200,200,200
rect 192,187,413,268
setrgb 1,100,200,100
line 190,227,415,227
setrgb 1,int(ran(250)+120),int(ran(250)+120),int(ran(250)+120)
  if hi=1 then
    clear fill rect 140,305,470,330
    rect 140,305,470,330
    text 150,320,"CONGRADULATIONS! NEW HIGH SCORE"
  fi
  if peek("port1")=16384 title()
  if peek("port1")=4096 error"Thank you for playing Green Boxcopter, coded by Sir Johnah.\nHope you enjoyed this installment!\nCheers, Sir Johnah\n>_<\n"
goto crash
end sub

sub controls()
'GET PLAYER CONTROLS
c=peek("port1")
  if and(c,64)<>0 then
    yp=yp+(4+up)
    rise=1
  fi
  if and(c,16)<>0 then
    yp=yp-(4+up)
    rise=1
  fi
  if and(c,8)<>0 pausing()
end sub

sub pausing()
ex1p=ex1
ey1p=ey1
ex2p=ex2
ey2p=ey2
smoke1=3
smoke2=3
smoke3=3
label pausing
ex1=ex1p
ey1=ey1p
ex2=ex2p
ey2=ey2p
  setdrawbuf db
  db=1-db
  setdispbuf db
draw()
level()
setrgb 1,100,200,100
clear fill rect 190,185,415,230
rect 190,185,415,230
text 218,210,"Hit X to Continue"
setrgb 1,200,200,200
rect 192,187,413,228
  if peek("port1")=16384 then
    smoke1=0
    smoke2=0
    smoke3=0
    main()
  fi
goto pausing
end sub

Edit- Added Code Tags To Source Listing
« Last Edit: September 21, 2006 by Clanky »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #1 on: September 20, 2006 »
Hey Clanky!  Great to see you over here!  Happy 18th brithday!

For folks who want to try this, you can download the PC yabasic player here
http://members.iinet.net.au/~jimshaw/Yabasic/ps2yabasic1.6b3.zip
or, if you're feeling more adventurous, you can try it on your PSP too
http://members.iinet.net.au/~jimshaw/PSP/pspyabasic1.0a.zip

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17422
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: My YaBASIC Game - Green Boxcopter
« Reply #2 on: September 20, 2006 »
 :hi: And I am just going to create a Yabasic area.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17422
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: My YaBASIC Game - Green Boxcopter
« Reply #3 on: September 20, 2006 »
Sorted.
Happy birthday by the way :) I need to download the Yabasic emulator now ( I don't have it any more!! Ooops! ) I still have some of my demos though so I should be able to help populate this board.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #4 on: September 21, 2006 »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17422
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: My YaBASIC Game - Green Boxcopter
« Reply #5 on: September 21, 2006 »
Excellent! I'll look through them. Maybe we'll even drum up a little interest in Yabasic again!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #6 on: September 21, 2006 »
excellent link there jim!

but when i tried downloading your chess it said the page you tried to access has been moved or something like that.

back on topic nice stuff clanky.
« Last Edit: September 21, 2006 by ninogenio »
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17422
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: My YaBASIC Game - Green Boxcopter
« Reply #7 on: September 21, 2006 »
Yes, I am going to sort out a copy of the emulator and play this game tomorrow :) I'll leave feedback.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: My YaBASIC Game - Green Boxcopter
« Reply #8 on: September 22, 2006 »
@Jim - is there a macintosh version of the YaBasic player? although i could try running it on my psp . . . ;)

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #9 on: October 04, 2006 »
i have started to try and finish the code. coding the boss! but i still cant understand why the collision isnt working properly??? making me real angry!!!  :whack:
well, if any YaBASIC knowhow people can help, then please do!!!!
Cheers!
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #10 on: October 04, 2006 »
->DrewPee - sorry, there's no Mac version of the player.
->Clanky, if you post the bit of the code with the collision problem I'll have a look.
This code collides a point with a rectangle
Code: [Select]
open window 640,512
b0x=220
b0y=256

b1x=320
b1y=256
b1w=40
b1h=30

repeat
setdispbuf d
d=1-d
setdrawbuf d
clear window
p=peek("port1")

if and(p,32)<>0 then b0x=b0x+1 fi
if and(p,128)<>0 then b0x=b0x-1 fi
if and(p,64)<>0 then b0y=b0y+1 fi
if and(p,16)<>0 then b0y=b0y-1 fi

setrgb 1,255,255,255
if b0x>b1x and b0x<b1x+b1w then
if b0y>b1y and b0y<b1y+b1h then
setrgb 1,255,0,0
fi
fi
fill rect b0x-1,b0y-1 to b0x+1,b0y+1
rect b1x,b1y to b1x+b1w,b1y+b1h
until (and(p,16384)<>0)
end
If that's any use?

Jim
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Collision Code
« Reply #11 on: October 04, 2006 »
thanx. yea, i know the basics for collision... but i can't seem to figure out why this collision is stuffing up  :(

heres the code for the game - only the bit which detects the collision...
WHERE:
     since the helicopter doesnt change X position, i have just stated the back of the helicopter as 38, and the front of the helicopter as 110... hope you understand?
     yp is the players Y co-ordinant
     ex1 is the current Block 1 X co-ordinant
     ex2 is the current Block 2 X co-ordinant
     ey1c1 is the current Block 1 top co-ordinant (ex1-size1)
     ey1c2 is the current Block 1 bottom co-ordinant (ex1+size1)
     ey2c1 is the current Block 2 top co-ordinant (ex2-size1)
     ey2c2 is the current Block 2 bottom co-ordinant (ex2+size1)

Code: [Select]
'COLLISION FIRST BLOCK
  if (yp-15>=ey1c1 and yp+15<=ey1c2 and ex1+5<=110 and ex1-5>=38) crash()
'COLLISION SECOND BLOCK
  if (yp-15>=ey2c1 and yp+15<=ey2c2 and ex2+5<=110 and ex2-5>=38) crash()

heres a bit of code which can simulate the collision for my game:
i have added visual aids to help with the positions of the collision! hopefully you can understand what is happening - and what is going wrong.

Code: [Select]
open window 640,512

xp=80
yp=256
spd=3
main()

sub main()
repeat
  setdispbuf db
  db=1-db
  setdrawbuf db
  clear window
setrgb 1,250,250,250
rect 38,yp-15,110,yp+15
line 111,yp-15,640,yp-15
line 111,yp+15,640,yp+15
get_blocks()
con()
collision()
until (peek("port1")=16384)
end sub

sub get_blocks()
'FIRST BLOCK
  if ex1<=0 ex1s=1
  if ex1s=1 then
    ex1=650
    ey1=int(ran(382)+100)
    size1=int(ran(50)+50)
    ey1c1=ey1-size1
    ey1c2=ey1+size1
    ex1s=2
  elsif ex1s=2 then
    ex1=ex1-spd
  fi
'SECOND BLOCK
  if ex2<=0 ex2s=1
  if ex2s=1 then
    ex2=650
    ey2=int(ran(382)+100)
    size2=int(ran(50)+50)
    ey2c1=ey2-size2
    ey2c2=ey2+size2
    ex2s=2
  elsif ex2s=2 then
    ex2=ex2-spd
  fi
'DRAW LEVEL BLOCKS
setrgb 1,250,250,250
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
end sub

sub con()
c=peek("port1")
  if and(c,64)<>0 yp=yp+4
  if and(c,16)<>0 yp=yp-4
end sub

sub collision()
  if (yp-15>=ey1c1 and yp+15<=ey1c2) O_o()
  if (yp-15>=ey2c1 and yp+15<=ey2c2) o_O()
'COLLISION FIRST BLOCK
  if (yp-15>=ey1c1 and yp+15<=ey1c2 and ex1+5<=110 and ex1-5>=38) collide()
'COLLISION SECOND BLOCK
  if (yp-15>=ey2c1 and yp+15<=ey2c2 and ex2+5<=110 and ex2-5>=38) collide()
end sub

sub O_o()
setrgb 1,0,250,0
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
line 111,yp-15,ex1,yp-15
line 111,yp+15,ex1,yp+15
end sub

sub o_O()
setrgb 1,0,0,250
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
line 111,yp-15,ex2,yp-15
line 111,yp+15,ex2,yp+15
end sub

sub collide()
setrgb 1,250,0,0
fill rect 38,yp-15,110,yp+15
fill rect ex1-5,ey1-size1,ex1+5,ey1+size1
fill rect ex2-5,ey2-size2,ex2+5,ey2+size2
end sub

hopefully you can see whats going wrong? and help with the bug!!! lol
thanx for you help
Cheers,
       Sir Johnah
       >_<
« Last Edit: October 05, 2006 by Clanky »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #12 on: October 05, 2006 »
I'm not sure what I'm looking at.
The basis of this is one rectangle colliding with another rectangle, right?

algorithm:
To check if two rectangles A and B intersect, once you've thrown away the obvious stuff of A being completely to one side/above/below B, you need to check each of A's corners to see if they lie in B, *and* you need to check each of B's corners to see if they lie within A.

Jim
« Last Edit: October 06, 2006 by Jim »
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #13 on: October 06, 2006 »
basically!
the main thing is the rectangle at the left side of the screen: your helicopter block
the blocks scrolling across the screen are the blocks for the game - there are 2.
the lines across the screen indicate where your Y position is relative to the blocks... if you are in line with the collision the line will change colour to either blue or green - block one, block two. this tells you that it has detected the collision, but since both X positions (you and block) are not equal or smaller than, then it will no calculate the hit.
if you hit the block... you turn red.

i think the problem is that all the helicopter has to be completely in line with the block to detect a collison....  i will give it a shot at fixing it, and see where i get!
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #14 on: October 09, 2006 »
I've been meaning to come back in here and add that the algorithm I posted isn't sufficient.  If two boxes cross each other in a plus shape + then no corners of either box are inside any of the points of the other box.  You need to check at least one edge as well.
Jim
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #15 on: October 10, 2006 »
not sure whats ment by the algorithm bit?
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #16 on: October 10, 2006 »
I was trying to give you a recipe for making code that detects reliably if two rectangles overlap, but I failed.  I should probably just write the code as a subroutine and post it up.

Jim
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #17 on: October 11, 2006 »
thanx... i knew what you ment to do, but i just couldnt understand what you were saying? if you could rite the routine, that would clear things up!  :cheers:
thanx again, i have tried to write the collision properly, but i just cant understand why it stuffs up!
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17422
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: My YaBASIC Game - Green Boxcopter
« Reply #18 on: October 11, 2006 »
Yabasic has a habit of strange happenings like that Clanky :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: My YaBASIC Game - Green Boxcopter
« Reply #19 on: October 14, 2006 »
yea bummer
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..