Re: CoolBasic Classic: Kehitysuutisten kommentit
Posted: Thu May 23, 2013 10:48 am
CBEnchanted on hyvä vaihtoehto tässä odotellessa.Pon wrote:ei tää koskaa valmistu prkl...
Game Making Should Be Easy...
https://www.coolbasic.com/phpBB3/
CBEnchanted on hyvä vaihtoehto tässä odotellessa.Pon wrote:ei tää koskaa valmistu prkl...
Asiasta sen enempää tietämättä täytyy myöntää että aika heikoltahan tämä näyttää.Timblex wrote:Onko kenelläkään tietoa siitä, että tuleeko mikään uusi versio coolbasicista koskaan valmistumaan?
axu wrote:Mitä tämä on? Blogiin on alkanut ilmestymään postauksia! Ilmeisesti siis kulissien takana oikeasti tapahtuu jotain, vaikka useimmat lienee jo menettäneet uskonsa CB:n paluuseen (allekirjoittanut mukaan lukien). Mukava lukea kehityksestä. Tsemppiä kehitystiimille!
Eli vaihdetaan koko vuosiluku?Zero wrote:Se hirveä weppisivu pitää korvata jossain vaiheessa.
Mutta laitetaan sitten kertarysäyksellä uusiksi...
Mites on kehityksen laita, kokonaisuutta ajatellen? Kuinka suuri osa työstä on tehty? Haluttaisi päästä tekemään jotain pientä peliä, mutta nykyinen cb alkaa olla jo niin vanhentunut ettei windows 8 pyöritä. Tästä kyllä tulee kaikkein paras ohjelmointikieli helppous/ominaisuus -suhteeltaan!Zero wrote:axu wrote:Mitä tämä on? Blogiin on alkanut ilmestymään postauksia! Ilmeisesti siis kulissien takana oikeasti tapahtuu jotain, vaikka useimmat lienee jo menettäneet uskonsa CB:n paluuseen (allekirjoittanut mukaan lukien). Mukava lukea kehityksestä. Tsemppiä kehitystiimille!
Miitin perusteella valmiina on editorin valikot, eli n. 72,69% kääntäjästä.skinkken wrote:Mites on kehityksen laita, kokonaisuutta ajatellen? Kuinka suuri osa työstä on tehty? Haluttaisi päästä tekemään jotain pientä peliä, mutta nykyinen cb alkaa olla jo niin vanhentunut ettei windows 8 pyöritä. Tästä kyllä tulee kaikkein paras ohjelmointikieli helppous/ominaisuus -suhteeltaan!Zero wrote:axu wrote:Mitä tämä on? Blogiin on alkanut ilmestymään postauksia! Ilmeisesti siis kulissien takana oikeasti tapahtuu jotain, vaikka useimmat lienee jo menettäneet uskonsa CB:n paluuseen (allekirjoittanut mukaan lukien). Mukava lukea kehityksestä. Tsemppiä kehitystiimille!
Höpö höpö juttuja, kaikki tietää että coolbasic on jo kuollut.Pettis wrote: Miitin perusteella valmiina on editorin valikot, eli n. 72,69% kääntäjästä.
Mie en tiennyt.Mikki0000 wrote:Höpö höpö juttuja, kaikki tietää että coolbasic on jo kuollut.Pettis wrote: Miitin perusteella valmiina on editorin valikot, eli n. 72,69% kääntäjästä.
Pitäis tietää...Awaclus wrote:Mie en tiennyt.Mikki0000 wrote:Höpö höpö juttuja, kaikki tietää että coolbasic on jo kuollut.Pettis wrote: Miitin perusteella valmiina on editorin valikot, eli n. 72,69% kääntäjästä.
Code: Select all
Rem Ball physics
By. MaGetzub
License: Do what ever you like with it. :)
EndRem
Include "AdvancedMaths.cb"
//You can modify these Constants how ever you like.
//A gravity
Const Gravity As Float = 9.81
//How many pixels on a screen is a meter, this is somehow misleading..
Const MeterPerPixel As Float = 100.0
//How much there's friction on a surface?
Const SurfaceFriction As Float = 1.25
//Screen size..
Const SW As Integer = 1280
Const SH As Integer = 720
//Collection of data for balls
Type Balls
Field mPos As Vector2 //Ball's position vector
Field mVel As Vector2 //Ball's velocity vector
Field mRad As Float //Balls radius
Field mMass As Float //Ball's mass
EndType
//Collection of data for collision handling between balls
Type CollisionPair
Field Ball1 As Balls //Ball1 handle
Field Ball2 As Balls //Ball2 handle
EndType
//Collection of data for walls
Type Walls
Field mStart As Vector2 //Starting coordinate vector
Field mEnd As Vector2 //Ending coordinate vector
EndType
//And let's put up a screen
SCREEN SW, SH
//Let's add some walls for the scene, so the balls cannot fall into void.
InitSegment Vec2(20, 20), Vec2(SW-20, 20)
InitSegment Vec2(20, SH-20), Vec2(SW-20, SH-20)
InitSegment Vec2(20, 20), Vec2(20, SH-20)
InitSegment Vec2(SW - 20, 20), Vec2(SW - 20, SH-20)
//We're not creating a new wall.
beginNewSeg As Byte = False
Repeat
//Show the fps in the window's title bar.
SetWindow "FPS: "+FPS()
//Let's set a drawing color
Color 0, 196, 255
//Let's draw some text for info purposes (in Finnish)
Text 0, 0, "Lisää seinä hiiren vasemmalla napilla."
Text 0, 10, "Lisää pallo hiiren oikealla napilla."
Text 0, 20, "Aseta pallojen suuntavektorit hiirtäkohti painamalla hiiren rullaa."
Text 0, 30, "Välilyönnistä puhdistaa liike-energiat."
newSeg As Vector2
//If mouse's second button is clicked and we are not creating a new wall
//let's add a ball with a random mass.
If MouseHit(2) And beginNewSeg = False Then
mass As Float = Rnd(10.0, 16.0)
AddBall mousex(), mousey(), mass, mass*3.0
EndIf
//If moue button is clickked let's start to adding a new wall.
If MouseHit(1) Then
beginNewSeg = True
newSeg.x = MouseX()
newSeg.y = MouseY()
EndIf
//Mouse button is down, let's draw a line between wall starting point and mouse position
If MouseDown(1) And beginNewSeg = True Then
Line newSeg.X, newSeg.Y, MouseX(), MouseY()
EndIf
//Mouse button is up, let's add a wall between wall starting point and mouse position, if the distance
//is more than 10px.
If MouseUp(1) And beginNewSeg = True Then
beginNewSeg = False
If Distance(newSeg.X, newSeg.Y, MouseX(), MouseY()) > 10.0 Then
InitSegment Vec2(newSeg.X, newSeg.Y), Vec2(MouseX(), mouseY())
EndIf
EndIf
Color 0, 196, 255
if KeyHit(46) Then
For b as Balls = Each Balls
b.mVel = Vec2(0, 0)
Next b
EndIF
//Let's update ball phyiscs
UpdatePhysics
//Let's draw balls
DrawBalls
//Let's draw walls
DrawWalls
//Limits fps between 60 - 70
Wait 15
DrawScreen
Forever
Rem
InitSegment adds a new wall into scene.
EndRem
Function AddBall(x As Float, y As Float, mass As Float, rad As Float)
//Let's initialize a rookie ball. :)
b as Balls = New(Balls)
//Let's set it's data.
b.mPos = Vec2(MouseX(), MouseY())
b.mMass = mass
b.mRad = rad
//Let's add a new collision pair between all balls, but not with the rookie one
For b2 As Balls = Each Balls
if b <> b2 Then AddCollisionPair b, b2
Next b2
EndFunction
Rem
InitSegment adds a new wall into scene.
EndRem
Function InitSegment(vstart As Vector2, vend As Vector2)
s As Walls = New (Walls)
s.mStart = vStart
s.mEnd = vEnd
EndFunction
Rem
AddPair adds a collision pair with given parameters.
EndRem
Function AddCollisionPair(ball1 As Balls, ball2 As Balls)
if FindCollisionPair(ball1, ball2) <> NULL Then return
pair As CollisionPair = New (CollisionPair)
pair.Ball1 = ball1
pair.Ball2 = ball2
EndFunction
Rem
FindPair deletes a pair with given parameters. Doesn't notice the handle order.
EndRem
Function DeleteCollisionPair(ball1 As Balls, ball2 As Balls)
pair As CollisionPair = FindCollisionPair(ball1, ball2)
If pair <> NULL Then Delete pair
EndFunction
Rem
FindPair finds a pair with given parameters. Doesn't notice the handle order.
EndRem
Function FindCollisionPair(ball1 As Balls, ball2 As Balls) As CollisionPair
//Let's search the pair list through
For pair As CollisionPair = Each CollisionPair
//We found a pair with same handles. Doesnt' matter in which order ball1 and ball2 are there
//If they are in reverse order we still recognize it.
if pair.Ball1 = ball1 And pair.Ball2 = ball1 or pair.Ball1 = ball2 and pair.ball2 = ball1 Then
//Pair found let's return it
return pair
Endif
Next pair
return null
EndFunction
Rem
HandleCollisionPairs handles every balls' collision
EndRem
Function HandleCollisionPairs()
For pair As CollisionPair = Each CollisionPair
//Let's calculate a collision vector between pair's ball2 and ball1
collision As Vector2 = Sub(pair.ball1.mPos, pair.ball2.mPos)
//Let's calclulate the collision vector's length
collisiondist As Float = Length(collision)
//Let's calculate which is the smallest distance between two balls
space As Float = (pair.ball1.mRad + pair.ball2.mRad)
//If distance is zero between balls' centers we do some hacks for
//preventing to divide by zero.
if collisiondist = 0.0 then
collision = Vec2(1.0, 0) //Let's set collision vector pointing to right
collisiondist = 1.0
endif
//Collision dist is less than the smallest distance between ball.
//Ladies and gentlemen, collision just happened!
If collisiondist < space Then
//Let's normalize the collision direction vector
collision = Normalize(collision)
//Let's save the old velocity
u1 As Float = Length(pair.ball1.mVel)
u2 As Float = Length(pair.ball2.mVel)
//Let's calculate the new velocity
//For ball1
v1 As Float = u1 * (pair.ball1.mMass - pair.ball2.mMass) + 2*pair.ball2.mMass*u2
v1 = v1 / (pair.ball1.mMass + pair.ball2.mMass)
//And for ball2
v2 As Float = u2 * (pair.ball2.mMass - pair.ball1.mMass) + 2*pair.ball1.mMass*u1
v2 = v2 / (pair.ball1.mMass + pair.ball2.mMass)
//Let's apply them by multiplying the normalized collision vector.
pair.ball1.mVel = Mul(collision, v1)
pair.ball2.mVel = Mul(Negate(collision), v2)
//Done!
EndIf
Next pair
EndFunction
Rem
DrawWalls function, draws every wall there is.
EndRem
Function DrawWalls()
For s As Walls = Each Walls
Color 0, 196, 0
Line s.mStart, s.mEnd
Next s
EndFunction
Rem
Balls function, draws a ball with given parameters.
EndRem
Function Ball(vector As Vector2, rad As Float)
Circle vector.x - rad, vector.y - rad, rad*2, false
End Function
Rem
DrawBalls function, draws every ball there is.
EndRem
Function DrawBalls()
Color 0, 128, 255
For b As Balls = Each Balls
Ball b.mPos, b.mRad
Next b
EndFunction
Rem
Overloaded linefunction to draw lines between coordinate vectors
EndRem
Function Line(v1 As Vector2, v2 As Vector2)
Line v1.x, v1.y, v2.x, v2.y
EndFunction
Rem
UpdatePhysics function, update physics of every ball. :)
EndRem
Function UpdatePhysics()
Color 255, 255, 255
//Let's handle ball to ball collisions.
HandleCollisionPairs
For b As Balls = Each Balls
//If user press the roll button on mouse, let's create some chaos by setting
//balls velocities towards the mouse.
If MouseDown(3) Then
b.mVel = Add(b.mVel, Mul(Sub(Vec2(MouseX(), MouseY()), b.mPos), 0.5))
EndIf
//Apply velocities to ball's position vector
b.mPos = Add(b.mPos, Div(b.mVel, MeterPerPixel))
//Apply gravity
b.mVel.y = b.mVel.y + Gravity
For s As Walls = Each Walls
//Wall's vector, the wall vector from start coordinate vector to end coordinate vector
lineVector As Vector2 = Sub(s.mEnd, s.mStart)
//Wall vector's direction
lineVectorDir As Vector2 = Normalize(lineVector)
//Wall's start to balls position vector
lineToPoint As Vector2 = Sub(b.mPos, s.mStart)
//Scale value where the ball is on the line
lineScale As Float = Dot(lineVectorDir, lineToPoint) / Length(lineVector)
//Helps the balls acting rightly in the corner cases
lineScale = Min(1.0, Max(0.0, lineScale))
//Let's multiply wall's vector with linescale, so we can get the position we can sum
//to the wall's start position.
ballReletiveToLine As Vector2 = Mul(lineVector, lineScale)
//Let's project balls position on the wall.
pointOnLine As Vector2 = Add(s.mStart, ballReletiveToLine)
//Now we can form a vector from the balls position and the balls projected position on wall,
//for correct the ball's position if ball is colliding with the wall line.
ballOnLineToBallCenter As Vector2 = Sub(b.mPos, pointOnLine)
//So the distance between ball and wall line is less tha ball radius, a collission has just been happened.
If Length(ballOnLineToBallCenter) < b.mRad Then
b.mPos = Add(pointOnline, Mul(Normalize(ballOnLineToBallCenter), b.mRad))
b.mVel = Mul(Reflect(b.mVel, ballOnLineToBallCenter), 1.0 / SurfaceFriction)
EndIf
Next s
Next b
EndFunction
Itseasiassa viestini oli harhaanjohtava ja käytin tuota "CBC" (Tulee sanoista CBCompiler) juttua ihan turhaan. Tämä Latexin repossa oleva CB versio ei liity varsinaisesti viralliseen CoolBasiciin mitenkään. Ja parempaa nimeäkään tälle ei olla viralliesti keksitty. Oma ehdotukseni on edelleen FrostBasic. Mutta kyllä, Latexi:n repossa oleva koodi on avointa, ja kuka vaan voi tulla mukaan kehitykseen.siis wrote:Coolbasic Classic on open source???????