Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / DarkNOOBS Project 4: Breakout

Author
Message
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 28th Jul 2009 23:52
Hmm, it works fine for me, except for when the paddle is moving towards teh ball during the collision, due to the fact that the ball can't escape and keeps getting collided with. Try using the HIT commands instead

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th Jul 2009 23:55 Edited at: 28th Jul 2009 23:59
u mean at the top of the subroutine?

ok

edit:

didnt work, made things worse

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th Jul 2009 23:59
heres a thought, what if we:

found the balls angle with atanfull (like you did)

found the opposite of that angle using wrapvalue(ballangle#+180), which would be the result of a flat head on collision

found the angle from the center of the ellipse to the point of collision

then averaged the two angles and made the result be the new ball angle?

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Jul 2009 00:19 Edited at: 29th Jul 2009 00:25
it could work, I still don't see what it the problem though with the current system, though.

[edit]
actually, I just thought of something. If you want it to be accurate to the shape, you need to change some things.

As said before:
Y=CenterY+YRadius*sin(angle)
X=CenterX+XRadius*cos(angle)

Taking the derivative (calculus stuff) will give the slope of the ellipse at each point (which you can find the normal to).

Y'=YRadius*cos(angle)
X'=-XRadius*sin(angle)

This angle can be found with ATANFULL

Normal#=ATANFULL(X',Y')

Add 90 and you should be good to go!

Note you probably won't be able to just copy and paste this. The angle here would technically be the angle from the center to the point of collision, but you could just as easily fudge it a little and make it the angle from center to center with minimal discrepancy.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 29th Jul 2009 00:24
if it hits somewhat from the top, it bounces off at 90 degrees, if it hits towards the sides it goes through the paddle parallel to the x axis

ill try that system later, i g2g now

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Jul 2009 02:16
GOT IT!

Here you are!



Also, it relies on a function I wrote to replace ATANFULL. I realized that it puts 0 degrees as straight down and goes counter-clockwise from there. This can be a problem as math equations treat right as 0. So I wrote this:



This will calculate it from right (0 degrees) to 360 degrees (just above right). It goes CLOCKWISE due to the coordinate axes, however if you need it to be counterclockwise (like normal angles are), just un-rem the first line of the function. The calls for the subroutine require it to be CLOCKWISE. Why? Because it worked. Why not counter-clockwise? Because I tried that and it didn\'t work.

Have fun!

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 29th Jul 2009 05:27 Edited at: 29th Jul 2009 07:08
[edited out]

edit:
nvm, my system turned out BEAUTIFULLY!!!:

I am especially proud of that first math line, multiplying by the reciprocal to find the angle of motion, a stroke of genius!!



and yes I know what you will say, "but its an elliptical paddle, you cant find the angle to the collision point using the CIRCLE formula", I AM AWARE!!! for our purposes it will do

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Jul 2009 09:46
Quote: "Ballangle=acos(ballmovex#*(1.0/ballmovex#)) "

Perhaps I am wrong, but wouldn't that just be the same as ACOS(1)?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 29th Jul 2009 21:31
wait.............wow that was stupid of me, lol

duh, I should have just used atanfull(ballmovex#,ballmovey#)

ok I did that and it doesnt work, will keep playing with it though

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 29th Jul 2009 22:21
Try using my function FindAngle that I posted above(or just see if my working code I posted works well enough). I like it better than atanfull because atanfull uses straight down as 0 degrees, which messes up some math. Mine uses straight to the right as 0 degrees and proceeds Clockwise to 360. Alternatively you can have it go counterclockwise by un-remming the first line in the function (I had to keep it remmed because it worked that way).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 29th Jul 2009 22:37
ummmm, I cant even run urs cuz im not sure exactly what to copy and paste, could you repost JUST case 3?

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Jul 2009 00:18
Well, case 3 is there. The if statement needs to go before the return of the subroutine (tried to just copy and paste the whole thing subroutine but was having trouble).

The function just needs to be somewhere in there.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 30th Jul 2009 00:21 Edited at: 30th Jul 2009 00:22
ok so it would work to have that flag check be in the main loop?

also is case 3 just till the first endcase or what?

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Jul 2009 00:33
I would imagine it would work in the main loop, I just kept it in the subroutine.

OOPS forgot to erase the first endcase. It was from the orginal case 3 and I just remmed it out. Take it till the second endcase (the one that doesn't have ` at the beginning of the line).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 30th Jul 2009 07:11 Edited at: 30th Jul 2009 07:19
do we even need that hitflag check?

the only way it can even get into the case 3 is if that collision is on

edit:

i was right, the hitflag variable is uneeded

also I tested urs, and it came out with the same result as mine, it works about 80-90% of the time but the other 10 it goes off in some unexplainable direction

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Jul 2009 13:39
The hit flag is to prevent the ball getting caught inside the paddle (resulting in the horizontal problem with the first release). It essentially changes the sprite collision factor to sprite hit. I tried just changing the line itself, but that messed up brick collision.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 30th Jul 2009 17:52
well I havent had that problem without the hitflag variable, but I wonder if that could be the reason the other problem is occuring?
curious

pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 30th Jul 2009 20:30
Y not instead of using a rounded paddle, just affect the direction the ball bounces off by the speed and direction the paddle is moving.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 31st Jul 2009 00:11
too unoriginal, its been done time and time again, I want to mix things up a little

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 31st Jul 2009 17:39 Edited at: 31st Jul 2009 17:42
And i'm also getting interested in this whole paddle-phisics thing....

Quote: "instructions are saved onto a .txt file
"


any plans to get them in-game?
if not i could, need sumtin ta do..

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 31st Jul 2009 18:08
they r already in game, I think the current update on the first page has em

just click help at the main menu and use right-left arrows to navigate

feel free to open the .txt file, its quite simple and very easy to improve on

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 31st Jul 2009 20:25
kk.

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 1st Aug 2009 07:06
Im startin to think the best way to do paddle collision is just like the original (although with the rounded paddle)

simple find the x diff between the paddle center an the ball, fill it into a simple equation to find the vertical and horiontal bounces

i might get to coding later today or tomorrow, right now Im trying to learn some 3d modelling with blender, but sunday im leavin on a 3 day leadership camp (zzzzzzzzzzzzzzzzzzzz) with likely no access to internet so sun-tue no coding or anything for me

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 2nd Aug 2009 01:41 Edited at: 2nd Aug 2009 01:42
k, I'll pick up where you leave off.

Quote: "simple find the x diff between the paddle center an the ball, fill it into a simple equation to find the vertical and horiontal bounces"


........Isnt that what we were doing before?

Edit)^
Um Never mind that last sentance, Lol.

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 2nd Aug 2009 04:33
ur right tho, but I meant rather than computing the anles based off the angle form the paddle to the ball, just use the x distances and fill it into 2 linear formulas

Lucky 13
16
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 2nd Aug 2009 20:58
Hi guys,

I know I'm not involved in your project but if you're having trouble with the ball movement before and after collision with the paddle (or any other objects), I have an idea. It's something I looked at when I was working on a 2D Pong clone a long time ago and came out with something that had the desirable effect.

If you'd like help with this, let me know and I can lend a hand. If you think I should butt out because I'm not really a member of the NOOBS, no problem. I'm a sort of noob but I know you've got your procedures.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 5th Aug 2009 04:59
YYYYYAAAAAAAAYYYYYYYYY, im back (if you didnt know I was at a leadership camp for the last 3 days (which was AWESOME btw!!)

anyway I would love your input lucky 13, I dont have a problem with non-members offering advice, especially on one this problematic

Lucky 13
16
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Aug 2009 11:56 Edited at: 5th Aug 2009 11:58
I'm not saying my suggestion if perfect or will you necessarily like it. If you decide not to use anything I've posted, I understand.

When I approached my Pong game, I gave the ball a variable called 'ballstate'. 'ballstate' would determine the movement of the ball in any of eight directions. For example,



So, when I checked for collision with other sprites, I would take the movement of the ball into consideration.



Here's a code snippet of a sprite collision with the 'ballstate' variable in play.



Finally, I would put 'ballstate' to work in another way by using it as the variable that defined the ball's position on screen.



The only problem with moving it using 'ballstate' is that (using my example above) if it doesn't collide with something it will fall of the play area. So you can either amend the movement code to take this into account, or you put invisible sprites at the edges of the play area so that the ball will automatically collide with them and change direction.

I hope this has made sense and that I haven't come across as condescending. I just want to help.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 5th Aug 2009 16:48
right, i like the idea

but it doesnt really fit our needs, I want a free moving ball, one that can move in 360 directions rather than the 8 you're showing

thanks though!

also btw, look into the SELECT, ENDSELECT, CASE, ENDCASE, and CASE DEFAULT commands, they would work well with your code

Lucky 13
16
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 5th Aug 2009 17:43
No problem. I just thought I'd pitch it since you're not 100% sure what method to use.

I will definitely look into those commands, thanks.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 6th Aug 2009 22:30
yes I am still thinking on this problem and the ame, althouh not much work has been done for a while

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Aug 2009 22:39
@That1Smart Guy
For paddle collision, one method is to give the ball a little more or less speed in the x direction based on how the paddle moves. It'll make the ball bounce off the paddle at various angles. So the paddle can be timer to sort of "hit" the ball in a direction. If it's the same x direction the ball is going, the x direction speed increases. If it's opposite, then the speed decreases. Though you'll want to limit how much extra speed can be applied and the maximum speed the ball can go. If you want, I can post a quick example.

Enjoy your day.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 7th Aug 2009 05:25
sure, post the example, the idea sounds intriguing but I just cant visualize it

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 7th Aug 2009 05:33
This whole problem is so confusing for me, so i'll stay out of it input-wise, but i'll be look forward to the example.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 7th Aug 2009 08:28
Smart Guy I offered the same suggestion as latch like 2 pages ago and you said no.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 7th Aug 2009 16:31
u probably worded it differently or someting, im sorry if I shot it down prematurely

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Aug 2009 02:18
Should I post the example, or pictionaryjr, are you gonna take a crack at it?

Enjoy your day.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 8th Aug 2009 05:50
both, lets make it a contest

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 8th Aug 2009 05:51
LOL. yeah a compo

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Aug 2009 10:44
When the ball is about to hit the paddle, move the paddle with the mouse to hit the ball in the direction you want it to go or to slow it down from the direction it is traveling by hitting it the opposite way.

bspd is the ball speed in either x or y direction
bdiry is the current y direction: positive or negative

I originally was controlling both directions with bdirx and bdiry, but decided I would just use speed for the x direction and have a negative or positive value so direction is already accounted for. I could've done the same for y, but left the code the way I originally wrote it in that regard.



Enjoy your day.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 8th Aug 2009 18:17 Edited at: 8th Aug 2009 18:32
i dont really like the idea of a speed controlled ball, but i do like your idea with the bspd and bdiry variables

this gives me an idea.......


edit:

YYYYYAAAAAAAAYYYYY!!!!!

i think ive finally come up with the solution!!!!!

i dont feel like drawing up an example so ill just explain:

upon paddle to ball collision, here is the process:



it works!!!!!!!!

I dont remember when the last update to the first post was made, so ill go update it now (gimme a minute)

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 9th Aug 2009 04:10
er.........yeah. i tried the download, it seemed the same as before didnt have enough time?

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2009 06:26
ya I launched the update, what u mean same problem?

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Aug 2009 04:39
oh nah, i download too quick
lol, we died.
theres like no one doing anything on the project.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 11th Aug 2009 04:44
I know

right now its me, BB, and Irojo

im coder, BB is artist, Irojo is audio

right now im kinda focussing on other projects, but I havent forgotten about this one

Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Aug 2009 05:17
Me neithr, been spyin' in on this thread, tho.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 13th Aug 2009 01:21 Edited at: 13th Aug 2009 01:21
You can give me a project to do.

But I still could'nt get the game to work. I even tryed all of your steps.Could you make a executeable of game for me to download and then see if it works.(the level editer works tho)

A Knight walks up to you and says,"Tell me somthing,if it is truth I'll kill you with my sword but if it is a lie I'll do it with magic."
What do you say to live?-The Elder Scrolls III
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Aug 2009 03:55
......hmmmmm, what error are you getting razer?

also ya I may give you a job soon, im kinda juggling a few other projects right now but I will get back into coding this soon

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 13th Aug 2009 22:32
If you can make a final executeable of the game it will tell me if I'm setting it up wronge or it's just this dang computer.

A Knight walks up to you and says,"Tell me somthing,if it is truth I'll kill you with my sword but if it is a lie I'll do it with magic."
What do you say to live?-The Elder Scrolls III
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 14th Aug 2009 00:22
ok heres the .exe of the game

heres what to do:

download this AND THE OTHER DOWNLOAD!!!!!!
then either create a new levels.txt file with the editor, or if I provided a sample (I forget if I did) then that will do
MAKE SURE THAT THE levels.txt file IS IN THE SAME DIRECTORY AS THE EXE!!!!
then just run the exe, but be prepared for it to crash as the exe isnt fully preped for a standalone exe yet and may crash if certain problems occur

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-20 11:14:45
Your offset time is: 2024-05-20 11:14:45