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 / The DB Classic Programming Challenge Thread

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th May 2007 19:07
Quote: "Monday 22 May, midnight GMT"


Monday is the 21st, so which one is it?


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th May 2007 19:18
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th May 2007 19:30
While writing my entry, I've come across the need to code something I've never done before - and it has me stumped!

It's to do with trajectories...

I know how to calculate a trajectory path, but the object isn't a sphere, it's an elongated object - like a javelin - and I can't figure out how to alter the angle of the object to match the direction it's traveling.

Essentially, the object has to always travel through the air 'point first' or it looks silly.

I've spent some time searching for 'trajectory', 'javelin' etc, but no luck do far. I'll continue looking, but if anyone has seen anything on their travels or knows how it might be done, give me a shout please!

TDK_Man

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st May 2007 01:09
@TDK

Well, two ideas come to mind off the top of my head. The first is looking at the javelin like a tangent to a circle. From flight point start A to flight end point B there's a distance the javelin would travel. Assuming there's gravity, it would be an arc. You can use the distance and the arc to determine the radius of the circle the javelin would be traveling on. From there you can get the polar coordinates of the center of the javelin. Think of the javelin as always being perpendicular to the radius so you would tilt the javelin accordingly. If the javelin was traveling down the z axis, the radius would be rotating around X, so the javelin would be tilting on the x axis.

The other idea is more complex and as I write it, too round about. It looks at either end of the javelin as a point on a line. The arc that is formed at the center of the javelin relative to the ground is treated kinda like a matrix. Divide the arc into segments of finite slopes. Get the normalized normal of each of these slopes. Use the Dot product to project each of the points at the end of the javelin relative to which segments they are over onto the normal. Use this method to get the projected height at either end of the javelin. Tilt the javelin so that the end points are at this height. I think I like the first method better!

Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st May 2007 01:15
OK - I'll have a bash with your first suggestion.

However, the last maths lesson I had was back in 1974 - and I was crap at it back then!

The trajectory stuff was only managed thanks to studying one of Phaelax's snippets for a fortnight and I got that working only knowing a half of what it means...

But, not long to go, so I'd better crack on I guess...

TDK_Man

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 21st May 2007 02:01 Edited at: 21st May 2007 02:31
My suggestion supposes a perfectly thrown javelin on a nice arc as opposed to on a parabola. I think it can be even simpler. If you can find the distance the javelin will travel - there's two velocities - forward and up. If there's no wind resistance we'll just make the forward velocity constant, the up velocity will change with gravity. So basically the javelin will go as far as it can in the forward direction until the up-down velocity makes it hit the ground. Distance1 = forward velocity*time ... and we can say time = -1*(up velocity - final velocity))/gravity or until javelin collision (remember gravity is in the negetive direction so time should end up positive)

Ok so far so good? Now if we know the javelin can travel a maximum of distance 1, and we unrealistically want the javelin to change it's pitch over this distance, then we take two angles : the start angle, and 0 degrees. The zero degree angle is the halfway point when the javelin should have leveled off.

Now we take the difference between the start angle and the middle angle and divide it by half of distance 1.

tilt = (start angle - 0)/(Distance1/2) - the start angle should be based on being between 0 and 90 degrees.

I have zero as the midpoint angle, but a little randomness in the routine here can make the javelin a little off when it finally hits the ground (more realistic)

Now for every n distance the javelin moves, you change the object x angle by tilt (assuming the pivot of the object is z oriented)

Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st May 2007 02:07
OK, thanks for that. Makes sense too!

It isn't actually a javelin - saying it was just made it easier to explain what I was after.

Just have to see if I can finish it in time!

TDK_Man

Comrade Robski
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 21st May 2007 18:30
Quote: "Monday is the 21st, so which one is it?"


Whoops! Lets make the deadline Tuesday 22nd May at midnight GMT so no one misses out!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st May 2007 20:56 Edited at: 21st May 2007 21:26
TDK, you could save the previous point on the trajectory path then find the angle between the new and old position. The very first step along the path won't be accurate because there isn't a previous point yet, but it'll pass before anyone notices. Actually, found a way around that, if you don't mind displaying your javelin just beyond time index "0.0".






NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 22nd May 2007 19:40 Edited at: 22nd May 2007 19:54
Here's my entry. I tried to do it in 3D but it wasn't too good so I did it in 2D. It's quite like Phaelax's one. The target move is 3 different ways and gets smaller and the speed increases. To make it harder I made the aimer shake a bit.




Nothing is impossible...
No really, it is.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd May 2007 04:36
Doh! I had a phone call and had to go out and fix a problem with a client this evening - and I'd planned to finish off my 3D archery entry.

Sadly it wasn't to be...

To be honest, I'd spent too long on what it looked like - and not enough on the actual firing.

Here's a screenshot of what I had when I ran out of time...



Shame it doesn't do a lot else!

TDK_Man

Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 23rd May 2007 05:39
I like it, good job .

Comrade Robski
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 23rd May 2007 11:17
Wow that looks great, TDK - I hope you'll finish it off someday, it will be great to play!

So, time's up, and there were two entries this time, Phaelax and NanoGamez guy.

Both entries had a similar feel to them, in Phaelax's entry you shot at a stick man - you could aim for different parts of his body (I say him, due to the notorious "Nut shot") and you scored points based on time.

In NanoGamez's entry you shot at a target, and got points based on how close to the bullseye you got. The target moved faster and got smaller as you progressed - also there were 3 different movement types, which added variation.

So I've decided that this time the winner is:



Congratulations to both entrants. The winner can set the next challenge!

Ps Sorry, like TDK I ran out of time for my entry - I'll post it if I get it finished before the next challenge is set.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd May 2007 19:23
congrats nano. I wasn't really expecting mine to be judged since it was the same entry I used for the DBP challenge. I'll update the entries to the site as soon as a new challenge is set.


Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 23rd May 2007 19:51
Congratz, Nano, can't wait to see the next challenge.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 23rd May 2007 19:53
congratulations nano, can't wait to see this next one, maybe i can finish it .

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 24th May 2007 18:57 Edited at: 29th May 2007 19:07
Thanks guys, sorry for the wait. Here's the next challenge:

Racing challenge

Specification

Make a racing game in 2D or 3D. Can be against the clock or against oppenents.

deadline

[EDIT]
New deadline:

2 weeks - Thursday, 7 June

Old deadline:

1 week - Thursday, 31 May


Nothing is impossible...
No really, it is.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th May 2007 05:47
Count me out, I got more to do next week than I have time for.


Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th May 2007 09:38 Edited at: 25th May 2007 09:39
I may enter, might not have time... how about a two week deadline?

Enjoy your day.
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 25th May 2007 13:40
I might have a stab at this... corners may be hard though. (me=newb)

The below sentance is true.
The above sentance is false.
Paradox!
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 25th May 2007 18:17
@ Latch:
If everybody agrees, then sure, if it's not against the rules.

@ Insert name here:
Give it a go, if you get stuck with anything then you can just ask here. Everybody's ready to help out.


Nothing is impossible...
No really, it is.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 26th May 2007 05:09
What a coincedence! I was just making an Anim8or tutorial for cars.
The car will probably the hardest part, though because you can only use DB Classic commands.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2007 05:47
I might have time with a 2 week deadline. But I'll be leaving town for a few days and then start a new job in a week.

Here's a hint for people, this is a good time to use a waypoint system.


Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 26th May 2007 05:59 Edited at: 26th May 2007 06:36
way point system? Oh, I'll just use the search tool to see what that is.
NanoGamez, How did you make the mouse shake like that? It was really cool, and I noticed you didn't put a single rem statement in your entry

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th May 2007 16:14
waypoints are a way to define a path. Think of a square with a "waypoint" at each corner numbered 1 through 4. You could also think of each point as a check point in a race. Then keep track of which points cars have passed. This not only gives you a way to have computer-controlled cars follow the path of the track but it also gives you an easier to way to calculate positions.


Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 26th May 2007 16:38
Interesting that everyone is assuming that it's a car racing game...

The below sentance is true.
The above sentance is false.
Paradox!
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 26th May 2007 19:21
I wasn't planning to do cars, I'm doing 2D squares.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 27th May 2007 00:00
Yay, I get the first entry!

Thank you!

The below sentance is true.
The above sentance is false.
Paradox!
Zombie 20
17
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 27th May 2007 00:24
Insert Name-Nice game, I think I went beyond a score limit or something so far as I was still alive and the text zoomed by and then the boxes stopped dropping. But nice job .

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 27th May 2007 02:44
Me too!!! But wasn't this a racing game challenge?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 27th May 2007 11:14
Technically, my game is a race because it is against the clock, and crashing loses you time. Hang on, I'll change it to the updated one where you CAN see the time.

The below sentance is true.
The above sentance is false.
Paradox!
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 27th May 2007 11:33
Sorry, won't let me edit my code!This one shows the score.

Thanks.

The below sentance is true.
The above sentance is false.
Paradox!
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 27th May 2007 14:58
@ TDK
You created this thread and the rules for it. Would it be OK to change the deadline to 2 weeks?


Nothing is impossible...
No really, it is.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th May 2007 18:00
it would be fine as long as we all agree, so I dont see a problem. Wish I had more than just a Mac with me.


TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th May 2007 18:57
As Phaelax says - there's no problem if everyone agrees.

If a challenge setter wants to make a two week challenge, that's fine by me.

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th May 2007 00:32
OK, Everyone agree?


Nothing is impossible...
No really, it is.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th May 2007 01:03 Edited at: 28th May 2007 01:20
Yes, I agree.
I have a problem with the Timer() function.
When I was looking at TDK's timer tutorial I wanted to make things so that every one second, something happened.
So, I used his 60 second timer thing, and changed it for 1 second. I did my little INC command, but, nothing happened. Can someone help me?
I also need info on how NanoGamez made the mouse shake

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th May 2007 03:49
If you want single second intervals, then you need to use a time interval less than one second because by the time you've counted to 1 it's gone and the timer is reset.

The Timer() function returns milliseconds (thousandths of a second) so you divide by 1000 to get the seconds.

Instead of seconds, use 10ths of a seconds by dividing by 100 instead of 1000.

You then need to count to 10 before doing the action because 10 tenths of a second = 1 second.

TDK_Man

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 28th May 2007 12:11
To make the mouse shake all you have to do is put this line in to your main loop:



It moves the mouse by -2,-1,0,1 or 2 everytime so it looks like it's shaking.


Nothing is impossible...
No really, it is.
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 28th May 2007 19:43 Edited at: 28th May 2007 20:43
Thanks guys! (not being sarcastic)
Woohoo!!!! My first entry!

Tell me if there's any problems because it had a lot of glitches while I was making it.

EDIT: Lol, this is just like Advert Attack on that weird Neopets game.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 28th May 2007 20:59
Sinani201 are you done with that anim8or tutorial yet??

I wrote some car code and I'd quite like a model for it .

E.D.

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 29th May 2007 03:22 Edited at: 29th May 2007 03:24
ooooooooooh. I'll start that...
BTW, I just started reading that book called Eldest. It's pretty good

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
MikeB
17
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 29th May 2007 11:13
Yeah .

E.D.

P.S. Great about the car tutorial, thanks

NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 29th May 2007 19:05
OK challenge deadline changed to 2 weeks - Thursday, June 7th.


Nothing is impossible...
No really, it is.
Link102
19
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 30th May 2007 00:45 Edited at: 31st May 2007 14:14
Here's my submission:

It's a checkpoint racing game useing floating vehicles.
- It features 1 pretty decent ai player. (for a first try)
- A smooth controled vehicle. (Controled by the directional keys)
- Adustable game length (check the length variable at the top, nr of checkpoints=length-3)
- A small camera effect (Zdepth)
- And a fancy animated win/lose screen

The objective of the game is to race the red checkpoints

cheers

Don't look at my sig!
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 31st May 2007 03:59
nice code.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Insert Name Here
17
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 31st May 2007 13:34
I like it!
I had to change the display mode at the start though.

The below sentance is true.
The above sentance is false.
Paradox!
NanoGamez guy
17
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 31st May 2007 15:01
Just checked the entries.

@ Insert name here:
Nice game 2D game with 3D objects, but the code's a bit untidy.

@ Sinani:
Wouldn't work. There isn't a youwin label. Mabye you didn't copy all the code.

@ Link:
Cool smooth controls and nice AI. Though it should have a speed limit because you lose control easily.


Nothing is impossible...
No really, it is.
Link102
19
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 1st Jun 2007 00:34 Edited at: 1st Jun 2007 00:36
I'm currently working on the ai, curretly he's wigling a lot. and to have a good control over the car, you'll need to slow down before hitting the target (just like when you'd use the checkpoints in track races >> slow down before hitting the corner) I don't have any problems controling the controling the car this way

Don't look at my sig!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Jun 2007 03:18
@ Nano

Is having tidy code a criteria for judging entries? If so, please list all the criteria used to determine a winner, as I don't see that in the post when TDK started the very first challenge. If not, and you were just giving friendly advice, okay. I hope to enter, but I'm not that familiar with the judging criteria.

Thanks,

LB

Login to post a reply

Server time is: 2024-04-23 16:41:06
Your offset time is: 2024-04-23 16:41:06