Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Yabasic => Topic started by: Clanky on December 13, 2006
-
Finally finished the code... with full collision detection!!! OMG!
I was listening to music last night having a relax, when I realised that: "Wow, so that's how you would do that! Just... oh yes... hmmm, and this... yep! Completed!" lol
Wow. It was simple, but I wont tell you guys and girls because you may get confused as I myself am confused at how I would tell you... but it is simple nother the less!
I have attatched it, because I am not sure if it will fit on the page?
-
Nice Collision Detection Cant seem to keep the copter airbourne
-
Huh! It should be in the middle of the sceen?
Can you fly the helicopter, or is it just that you hit the blocks?
-
I can't fly the thing it keeps plummeting to the ground. Perhaps I should be holding X instead of tapping it faster?
-
That caught me out the first time I played, holding X sorted it out. It's a great game. There's something quite charming about the simplicity of Yabasic games, we had a competition on the old ezboard to make a one button game before and some of the entries were really inventive.
-
Cool game, and nice smoke effect.
EDIT:739, level 5.2 and the walls had started to shake around.
-
My mistake, I just ran it again and you use the D-pad to move. It's a bit tricky in the emulator :)
-
woops!
Do you have to press the D-Pad??? Hmmm.... I thought it was X.
Well then. Cheers for the comments, and a Happy New Year to everyone!
-
OK. Yes, you need to press the D-Pad (UP) Button to fly the helecopter... note you can tap it.
I made it so you can slow it down with force=0.02 (Note: FORCE is force slow down...)
Updated Version is attatched.
Hope everyone likes the special sequences of the harder levels!
Cheers.
-
Love the smoke man,
This is still a very challenging game i find but at least I can control the chopper now, controls are smooth excellent work I'm gonna see if I can get off the first level.
:cheers:
-
Ok, I had a read of your post rain_storm on the other topic... and I think I like the idea. I will start to make the Green Boxcopter game bigger!
Thanx for your insight, and I will be adding other special additions to the new one {hidden}, and if I need more explaining on the rotation and collisions, I know where to ask!
-
Will be cool.. In fact I found a very similar game to this and added it to the arcade, yours is better though :)
-
I'm grad you're gonna add some more touches. If things get a little hairy I will help if I can, :cheers:
-
Ok, I have finished one of the new additions - actually yesterday.
I think I will attatch both the old GB and the new one in the same post, so that people can compare them. Also, I think that I will make it so that the old one is called "Green Boxcopter: Equality" and the new one "Green Boxcopter: Seperation"... explainations in the Read Me.txt which I will attatch with the release of the new game.
I have a few other ideas which I am starting to write down and think about, this is comming along nicely! I will do the rotating blocks last - as they will be the most difficult!
Thanx!
-
Sounds like this project has been given a kick in the butt and things are moving foward, its nice to see. may I suggest sparks or something extra like that when the copter hits into something, you know fancy explosions and all that. That would be a nice addition
-
Yep! Thanx Rain_Storm. I actually thought of this way back for the old game, but the effects made the game slow down dramatically.
So, I am trying to code a new faster model.
Here's the code... note that it - for some reason - doesn't work properly. It doesn't 'explode'... rather just falls in four blocks...
open window 640,512
part=100
dim px(part),py(part)
dim s(part),pd(part)
dim r(part),g(part),b(part)
label loop
setdispbuf db
db=1-db
setdrawbuf db
clear window
fire=fire+1
if fire=100 onu=1
if onu=1 then
for i=1 to part
grav=0
px(i)=320:py(i)=256
s(i)=ran(2)+2:pd(i)=int(ran(4))
r(i)=ran(200)+50:g(i)=ran(50):b=ran(50)
next i
onu=2
fi
if onu=2 then
for i=1 to part
if pd(i)=0 then
px(i)=px(i)+(ran(2)+2)
py(i)=py(i)+(ran(2)+2)
elsif pd(i)=1 then
px(i)=px(i)+(ran(2)+2)
py(i)=py(i)-(ran(2)+2)
elsif pd(i)=2 then
px(i)=px(i)-(ran(2)+2)
py(i)=py(i)+(ran(2)+2)
elsif pd(i)=3 then
px(i)=px(i)-(ran(2)+2)
py(i)=py(i)-(ran(2)+2)
fi
grav=grav+0.0015
if grav>5 grav=5
py(i)=py(i)+grav
setrgb 1,r(i),g(i),b(i)
fill rect px(i)-s(i),py(i)-s(i),px(i)+s(i),py(i)+s(i)
next i
fi
goto loop
I have part set to 100 so it shows more particles... it can be lowered though.
-
you could boost that by only calculating one side (fowards or backwards) then draw the particals as they are relative to the crash point and a mirror image on the opposite side
Also ran() is slow so just randomise the movement values and store that to an array
open window 640,512
part=100
dim px(part),py(part)
dim s(part),pd(part)
dim r(part),g(part),b(part)
dim movex(part),movey(part)
label loop
setdispbuf db
db=1-db
setdrawbuf db
clear window
fire=fire+1
if fire=100 onu=1
if onu=1 then
for i=1 to part
grav=0
px(i)=000:
py(i)=000
s(i)=ran(2)+2:
pd(i)=int(ran(4))
r(i)=ran(200)+50:
g(i)=ran(50):
b=ran(50)
if pd(i)=0 then
movex(i) = ran(2) + 2
movey(i) = ran(2) + 2
elsif pd(i)=1 then
movex(i) = ran(2) + 2
movey(i) = -ran(2) - 2
fi
next i
onu=2
fi
if onu=2 then
for i=1 to part
px(i)=px(i)+movex(i)
py(i)=py(i)+movey(i)
grav=grav+0.0015
if grav>5 grav=5
py(i)=py(i)+grav
setrgb 1,r(i),g(i),b(i)
fill rect 320+px(i)-s(i),265+py(i)-s(i),320+px(i)+s(i),256+py(i)+s(i)
fill rect 320-px(i)-s(i),256+py(i)-s(i),320-px(i)+s(i),256+py(i)+s(i)
next i
fi
goto loop
-
Thanx Rain, I'll take that into account.
But, there is one problem with my explosion... id doesn't seem to explode in 'all' directions. Just four blocks going:
1: Up and Left (With Grav Force Down)
2: Up and Right (With Grav Force Down)
3: Down and Left (With Grav Force Down)
4: Down and Right (With Grav Force Down)
And with your edited one, it has another just falling straight down...
Hmm... I will see what happens with a few other ways - I'm just hoping I can get a circle spray explosion.
-
I know what you mean take a look at this code, the y movement values are randomised by two random values (one positive the other negative) whilst the x movement is simply randomised positively with an extra non random number added to it. note the end result displays this peculiar gap both below and above the explosion. Thats because the non random addition to the x axis forbids any partical from entering these zones try setting that non random value to zero and observe the results - The problem will dissappear ;D
open window 640, 512
window origin "cc"
gravity = 0.01
size = 4
nonrandom_value = 2
00 parts = 50
dim partx(parts), party(parts)
dim movex(parts), movey(parts)
for p = 0 to parts
partx(p) = 000
party(p) = 000
movex(p) = ran(2) + nonrandom_value
movey(p) = ran(2) - ran(2)
next
blast_radius = 0
01 setdispbuf draw
draw = 1 - draw
setdrawbuf draw
clear window
02 if (blast_radius < 150) then
setrgb 1, 255, 100, 100
fill circle 0,0,blast_radius
circle 0,0,blast_radius*2
circle 0,0,blast_radius*3
blast_radius = blast_radius + size
fi
03 setrgb 1, 255, 000, 000
for p = 0 to parts
px = partx(p) + movex(p)
py = party(p) + movey(p)
fill box px-size,py-size to px+size, py+size
fill box -px-size,py-size to -px+size, py+size
partx(p) = px
party(p) = py
movey(p) = movey(p) + gravity
next
04 if (inkey$(0) <> "") goto 00
goto 01
-
Yep. That is more of an explosion! Thanx.
But, I have seen a really nice explosion before done in YaBASIC... I just can't remember where it is! I think it was in the package Jim put together on the Yab Site...
It was really something! Full circle explosion, ahh - it was great! Now if I could just find it...
I think it may have used sin/cos to move the particles around... and, as I don't know how to use sin/cos very good it will be impossible for me to code it. So i needa find the explosion code... arg!
Thanx for your help Rain, very much appreciate it!!!
-
It would be nice to have a full blast effect in all directions I will try searchin the ezboard for that proggy. it would be a great addition to the "Look what I found" thread
-
Ok, after realising that there was actually a really good explosion effect on the Ezboard Fourms, I decided to investigate and get the code! And, hey presto! - Here it is!!! It's small, and all that needs changing is the High Score display... so, it's all there! YAY! :clap: :updance:
This code: Originaly Coded by Jinx @ Ezboard Forums
link: http://p205.ezboard.com/fyabasicprogrammingfrm2.showMessage?topicID=283.topic
3rd Reply, 09/06/03, 3:57PM
open window 640,512
gosub setup
hi_score=int(ran(1000)+500) REM random high score
repeat
clear window
gosub fireworks
setrgb 1,50,200,200
text 320,195,"New High Score!","cc"
text 320,210,str$(hi_score),"cc"
gosub db
until(peek("port1") > 0)
end
label db REM - DOUBLE BUFFERING
setdispbuf draw REM - FOR SMOOTH ANIMATION
draw =1-draw
setdrawbuf draw
return
label fireworks
alow_fire=alow_fire-1
setrgb 0,0,0,alow_fire/4
if alow_fire<0 then
new_fire=1
fi
for a=1 to num_part
fire_x(a)=fire_x(a)+fire_vx(a)
fire_y(a)=fire_y(a)+fire_vy(a) rem +.5
next a
if new_fire=1 then
new_fire=0
alow_fire=120
fx=ran(640)
fy=ran(200)
color_r=ran(100)+155
color_g=ran(100)+155
color_b=ran(100)+155
for a=1 to num_part
fire_x(a)=fx
fire_y(a)=fy
ang=ran(360)
fire_vx(a)=cosi(ang)*(ran(3)+.5)
fire_vy(a)=sine(ang)*(ran(3)+.5)
next a
fi
col=alow_fire/120
for a=1 to num_part
sz=ran(3)+1
setrgb 1,color_r*col,color_g*col,color_b*col
fill rect fire_x(a),fire_y(a) to fire_x(a)+sz,fire_y(a)+sz
next a
return
label setup
dim sine(361),cosi(361)
for a=0 to 361
cosi(a)=cos(a*(pi/180)) REM - PRECALCULATE
sine(a)=sin(a*(pi/180)) REM - SINE/COSINE
next
num_part=75
dim fire_x(num_part)
dim fire_y(num_part)
dim fire_vx(num_part)
dim fire_vy(num_part)
return
So, after Yah Spaced Invaders is finished, I will try and get Green Boxcopter done properly!!! Hopefully soon-ish. Also, I had a look at my Computer Crisis Clone - going back to the Ezboard days - and I believe that I can make it better (less code - using enemy_x(2) and so on, and fix the collisions and have power-ups!) So, when Green Boxcopter is done, I will go back to CC and try and get that good... finally get some finished games into my yabasic library:
Green Boxcopter 1; *finished*
Green Boxcopter 2; *alomost*
Yah Spaced Invaders, and; *kinda*
Computer Crisis II. *done, but needs moding*
haha!