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 Professional Discussion / - DBPro Coding Challenges -

Author
Message
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 16th Sep 2006 20:27
Just so you guys know - I got DBP-Site up to date. Its got the last 3 challenges in + I've updated a couple of modules. For example, when you select a user from the "Entries By Person" section, it tells you if they won with that entry or not.

[center]
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 16th Sep 2006 20:54 Edited at: 16th Sep 2006 21:02
Thanks, I'm trying to figure out how to make the boxes stop bouncing. Working on an autofreeze feature, a continuous contact detection, and forces.

The new features look cool Nick. You could add a link that goes from the page that display's a person's entry to the page that displays all the challenges that person was in. Ie link all pages like http://www.dbp-site.com/challenges/paint-program/nicholas-thompson to pages like http://www.dbp-site.com/entry-by-person/Nicholas+Thompson.

Edit:
And linking from the website to this thread would help whoever happens to find the site not from this thread, like through a search engine.
RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 16th Sep 2006 20:55
Wow LL! That is great!


Open MMORPG: It's your game!
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 16th Sep 2006 20:59
Interesting... I do like the sound of that. I'll put my thinking cap on. Not only would that be fantastic for users - but it would also be great for SEO (Search Engine Optimisation) too!

I've just looked at the stats... In the first week of september I was getting an average of about 30 unique visitors a day - last week I got an average of over 60 a day!

[center]
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Sep 2006 08:24
I'm outa town with only my mactop (so no code testing), so I'll just take everyones words for how things are turning out. Should be back sometime next week.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Sep 2006 12:34
LL: I was going to buy Dark Physics ....... don't think I'll bother now!

I'm trying to figure out why the boxes keep rotating for longer than you'd expect ... when a corner of a box smacks against the floor (or another object), it doesn't appear to lose much of its angular momentum.
Image All
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 18th Sep 2006 07:30
What Ric said, and add some friction

But about the rest of it:

Usually you'd expect this kind of handling from a C++ physics engine... but in a basic language, this is a genuine w00twork

FunkyStickmen: Battle of the Races (1%)
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 18th Sep 2006 19:36
Here's a 2D orbital simulation. Starts with a stable sun, planet, moon orbit. (stability not guaranteed).
Most of the code is for handling input to set up your own objects.
Code at the end does the actual plotting of orbits using square of the distance formula.



( 2b || !2b ), that is the question. The answer: true
Cave Man
19
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 19th Sep 2006 18:26
I've managed to get multiple balls to react to eachother. But its acts odd once they get to close to the floor.


Your signature has been erased by a mod because it's larger than 600x120
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 20th Sep 2006 01:12
That's some pretty awesome code there Cave Man.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Sep 2006 23:40
Instead of using cls 0, try pasting a translucent black image to the screen that is 95% transparent by using the fill tool at 5% opacity. You get some really cool trails if you set the bounce to 1.0 and uncomment the bit that puts the ball just above the floor

Cave Man
19
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 22nd Sep 2006 03:43 Edited at: 22nd Sep 2006 19:48
Thats a good idea diggsey, i'll have to figure out how to do that without media though.

Here's the current bouncy balls.

added:
- you can pick the balls up and throw them
- a red floor

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Sep 2006 19:05 Edited at: 22nd Sep 2006 19:06
@acelepage, pretty cool with the customization. Maybe do our 9 (or 8 depending on you anti-Pluto people) planets and set a slider bar or something to select a time frame; like 1 and 360 days.
Your program gave me a neat idea for a constellation simulation.

@caveman, neat. Collision seems a little dodgy and when I pick up a ball and release it, it seems to shoot in its previously determined direction. I just expected it to drop or something.

@LowerLogic,


Can't seem to find what would be causing this. I was able to run your first example just fine, but not this latest entry.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Cave Man
19
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 22nd Sep 2006 19:49
Quote: "it seems to shoot in its previously determined direction."


Fixed it. At least i think i did...

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Sep 2006 19:50
This will fix your throwing problem:


It is the same, but with mousemovex/y called every loop, because they return the move distance since they were last called

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Sep 2006 20:15
This is your program, with collision fixed



Cave Man
19
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 22nd Sep 2006 20:42 Edited at: 22nd Sep 2006 20:43
Sweet. I Played with two balls only and found it bounces to the opposite direction that it should.

so i changed the part
angle1#+angle2#
to
angle1#-angle2#

heres the current code


Thanks diggsey for the balls not chrushing into each other.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Sep 2006 20:49
I like fixing peoples code, because the mistakes I would make are the ones others would get right, and the mistakes they make, I usually get right

lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 23rd Sep 2006 05:25
@Phaelax
Perhaps the problem is on the line where I display the x an y velocity of the selected object to 2 decimal points using str$(body(last_body).v.x,2). Try taking out the ",2" from the str$ statements to see if that fixes it.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Sep 2006 08:26
That fixed it.

I broke it. After awhile, I moved one block which managed to make all blocks flicker around crazily. Blocks never seem to come to rest and also rotate a bit much I think. Overall, pretty darn cool.

Everyone else has their work cut out for them now.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Sep 2006 16:56
@LL
Try dragging an object to the bottom left, then really quickly, drag it to the top right and back. Do this for a while, and all the objects will begin to flicker between two places either on or off the screen. Also, blocks can get lost off screen!

Also, try this:
Turn off gravity for the long thin object, the small object and a medium square object.
Use control+shift to stop them moving, and drag the long object so that it hangs partially over the edge of the ledge. Put the small object on the end on the ledge, and put the big object in the air above the other end (still using ctrl+shift). Then, turn gravity on for the small object, and then quickly, the big object as well. It does not act like a see-saw, but just wobbles a bit. If you could fix that, then it would be even better!

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Sep 2006 06:42
Only 2 days left!

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Sep 2006 13:46
That went quick!! Well here's my effort. As I said I would, I've had a go at demonstrating the magnetic field around a bar magnet.

Use the mouse to drag the magnet around the screen to see the field update in real time.



If I get any more time on this before tomorrow, I might add in some options - like more than one magnet, type of magnet, strength of magnet etc.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Sep 2006 19:36
That's kinda trippy looking at.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Sep 2006 19:44 Edited at: 25th Sep 2006 19:45
Getting more trippy .....



The image shows the intersection of two magnetic fields. A little bit more to do and then I'll post the updated code.
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Sep 2006 20:40
I can't seem to post my code - is there a new limit on the size of a code snippet or something?
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Sep 2006 20:42
Maybe try to attach it as a txt file?

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Sep 2006 20:48 Edited at: 25th Sep 2006 20:55
Good idea. Code attached as .txt

Controls:

Left mouseclick+drag to move the magnets
Right mouseclick and drag to rotate the magnets

Enjoy!
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Sep 2006 22:14
Sweet Jesus he's back!

[center]
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Sep 2006 22:28
Nice! When I thought of 2D physics I never would've thought of this! But now I'm going to break your heart... don't the filings move?

Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Sep 2006 23:16
Usually they do. Thats whats odd! I thought something didn't quit look right. Thats gonna be a bitch to code... (And thus the challenge is set )

[center]
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Sep 2006 23:19 Edited at: 25th Sep 2006 23:21
If they were able to move freely, they would all just stick to the poles of the magnet, and you wouldn't see the field pattern. In the real life demonstration, you sprinkle the filings onto the paper and keep the magnet still (under the paper). If you move the magnet, the filings do get stuck to the poles and the pattern disappears. I wanted to be able to move the magnets though.

I once saw a nice demonstration which had the filings in a clear donut shaped container filled with a clear jelly like liquid. The magnet was placed in the centre of the donut and the the filings were able to rotate, but because the jelly was quite thick, they weren't able to move much - preserving the field pattern.
Fangz
19
Years of Service
User Offline
Joined: 16th Sep 2006
Location:
Posted: 26th Sep 2006 05:06
Here is my entry. I can't figure out how to get the circles to collide with each other and bounce off in a realistic way... maybe someone could help a newcomer?


Don't memorize, understand.
Cave Man
19
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 26th Sep 2006 16:05 Edited at: 26th Sep 2006 16:09
That's really neat Ric.

I managed to make a trail like diggsey suggested. I also made it so the balls don't get shoved into the floor or the walls. Next i think i'll add static shapes that they can hit.


Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 26th Sep 2006 16:43 Edited at: 26th Sep 2006 16:44
Had a bit more of a think about Nick's and Zoto's comments about the filings not moving - I decided to add it in as an option, and try to create a 'filings floating in liquid jelly' type feel. It actually works really well, and is far more fun to play with now! The filings do eventually get stuck to the poles of the magnets, but you can give the magnet a bit of a shake and they fall off. Also, because you can adjust the strengths of each of the two magnets, you can play tug of war with the filings - hehe!


Code to follow later.

Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 26th Sep 2006 17:37
Here it is - as a .txt again because I can't seem to post it in the usual way.

Select 'movement on' from the menu to see the filings move.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Sep 2006 19:35 Edited at: 26th Sep 2006 19:36
Ric, I can't get any filings to show up, only the magnets.

I'll give everyone til the end of the day, since I never said what time it ends today.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Sep 2006 20:39
Ric - thats fantastic. It even works (well) on my work machine which, as I've said many times before, has all the graphical prowess of a crayon on damp paper.

@Phaelax - did you actually set any filing amounts?

[center]
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 26th Sep 2006 23:08
Thanks Nick!

Quote: "Ric, I can't get any filings to show up, only the magnets."


Really? It should automatically start with 1000 filings on the screen. There may be some kind of graphics card issue I guess .... I'll take a look at it, and I'll post an exe just incase as well. Just off for some dinner first, though. Yum.
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 27th Sep 2006 00:22 Edited at: 27th Sep 2006 00:24
Well - I can't see any obvious issues, like drawing outside the bitmap area. Maybe a z-buffer issue, with so many 3d planes occupying the same z-depth. Here's a zipped exe anyway. Hope this works!

Controls:

- Left mouseclick and drag to move magnets
- Right mouseclick and drag to rotate magnets
Fangz
19
Years of Service
User Offline
Joined: 16th Sep 2006
Location:
Posted: 27th Sep 2006 02:53
Here is my entry:

Thanks very much to dark coder for helping me with the collisions. I am fairly new to darkbasic so I thought this was really really good, but it probably isn't Let me know if I should add or change something

Don't memorize, understand.
lower logic
20
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 27th Sep 2006 07:02 Edited at: 27th Sep 2006 08:24
Ric, that snippet is really really, cool.

Anyway, here's my final entry. There's still a few bugs with the torque, but it looks right most of the time. Friction should work ok, and I also added some motion blur. Code:

edit: removed the precision argument to the str$() commands and gave the boxes slightly brighter colors.
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 27th Sep 2006 10:48
@Fangz: That's very nice. A couple of things I noticed - firstly, the circles were tending to get stuck at the edges of the screen sometimes. Problem easily solved by adding a section to tell them that if they are over the edge of the screen, to bring them back to the edge:




Also note that I've multiplied the velocities by 0.8 to give the effect of a little damping when they rebound off the edges.

Secondly, I can see that you intended to give them random initial velocities between -0.5 and 0.5 by using rnd(1)-0.5. The problem is, rnd will only return integer values (whole numbers), so rnd(1) will only ever return 1 or 0. So the initial velocities will always be -0.5 or 0.5, but nothing inbetween. To solve the problem, use rnd(10)/10.0-0.5. This will produce a random number between 0 and 10, and then divide the answer by ten to give a number between 0 and 1 to one decimal place. To give a random number between 0 and one to two decimal places, do rnd(100)/100.0, then subtract the 0.5 to make the range -0.5 to 0.5.

@LL: Looking better. The friction seems to work well.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 27th Sep 2006 11:17
Wow I'm glad I dont have to judge THIS one!

I cant believe that boxes one is pure code physics - its amazing!

[center]
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Sep 2006 18:54
this is tough. be back in a minute with the results.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Sep 2006 19:57
Zotoaster, pretty cool. runs smooth, not apparent bugs. I like how you can display the vectors on each circle and the wind factor was nice.

spopovich, good start. Makes me think of donkey kong. The ball doesn't seem to have any forward velocity when it drops to the next platform. I would've liked to see this developed further.

acelepage, good start. I could never really get much from the custom objects, they just flew off the screen.

Fangz, nice collision/response demo. We coulda used you at one of our earlier challenges, billiard-physics.

cave man, nice ball collision and user-interaction. I liked the trails effect, nice touch.

Ric, definately a unique take on this challenge. user-interaction, customization levels. (though 2000 filings became quite slow)

LowerLogic, very nice OBB collisions and response. Your final demo gave me some drawing problems. Not sure if they were intentional or not. Boxes didn't leave trails, but the background sorta did. Still nice. Although, a rotating box never seems to stop rotating unless I make it.


Runner up:


And the winner is......


"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 27th Sep 2006 20:51
Well done!
I might give the next challenge a go, depends what it is

Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 27th Sep 2006 22:39
Woohoo! Thanks Phaelax.

I'm probably going to keep working on the magnetism program. There have to be science teachers out there who would use this in a classroom. I'm thinking I'll give it some more features, a nice front end menu, and a lot of polish, then try and release it as a 'proper' piece of software. See what happens.

I also really like LL's entry, it really was a serious piece of work - definitely the most advanced physics engine I've seen in DBP that is written in DBP. Hope you keep working on it.

Give me some thinking time, and I'll post the new challenge shortly.
Spopovich
19
Years of Service
User Offline
Joined: 12th Jul 2006
Location:
Posted: 27th Sep 2006 22:48
Wish I had spent more time on mine, though I must say wow. Those were some amazing enteries. Ric that was really cool simulation, and Lower logic.... that was amazing, I have no idea how you did that. Anyway congrats Ric and I hope to devote more time to the next challenge and that I won't give up as easily this time.

Do not ask what the forums can do ask what you can do for the forums.
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Sep 2006 23:48
Nice one Ric. Everyone did brilliantly on their entries. Who needs darkPhysics after all?

Looking forward to the next challenge!

Login to post a reply

Server time is: 2026-07-09 23:32:13
Your offset time is: 2026-07-09 23:32:13