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
gadgetfreak 66
19
Years of Service
User Offline
Joined: 26th Sep 2006
Location: Kulin,WA, Australia
Posted: 31st May 2007 14:45
I agree about the unnecessary calculations, and a box overlap check should work well. There's still another problem though, being that this method so far doesn't work when either line is perfectly horizontal or vertical. Something to do with having a gradient of 0 or infinity, I think. Haven't had a play yet but I'm sure there's something that can be done.

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 31st May 2007 21:30
I started on a small asteroids game. Right now it's just the spaceship zipping about, but i hope to add in some asteroids in a little while. Don't know if I'll ever be able to figure out the collision detection. Any hints or additions are welcome.



- enderleit
[href]www.eleit.dk[/href]
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 31st May 2007 22:42
I added some asteroids now!



- enderleit
[href]www.eleit.dk[/href]
Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Jun 2007 11:57
Good job so far Enderleit - and welcome to the DBPro Challenges! I hadn't thought of doing something like Asteroids for this challenge, but I suppose it is lines+physics after all! I noticed you precalculated your sin and cos tables - that's a neat little trick for improving efficiency.

Once we have figured out the line intersection code, we should be able to turn it into a nice little function, and you should be able to use it for your collision. However, as Gadgetfreak spotted, it seems to have a division by zero problem in some cases, so it needs fixing first!

Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 1st Jun 2007 17:22
Isn't that roughly how sin/cos is done nowadays? Doesn't the internal/low level language have a lookup table of function's like that? If you provide a value between two indexed ones, it linearly interpolated between them... Example:
20.0 degrees = 0.0
40.0 degrees = 10.0
Therefore, 30.0 degrees = 5.0

[center]
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 1st Jun 2007 17:40
@enderleit - nice piece of code.

A suggestion:
I added 4 global variables to your code xmin, xmax, ymin, ymax.
They are for the left, right, top, bottom screen coords.
They are beyond the visible screen area, so your asteroids and ships
won't pop off the screen and pop on the other side, but will seem
to float off the screen edge and slide back on the other side, just a little more appealing I think, just my suggestion.

Good work so far!
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Jun 2007 14:15
Quote: "Isn't that roughly how sin/cos is done nowadays? Doesn't the internal/low level language have a lookup table of function's like that?"

Actually, there are processor instructions to calculate sin and cos.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Pharoseer
19
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 2nd Jun 2007 20:05
I was getting frustrated trying to run your code enderleit. I kept getting the error message "Variable 'rocky#' does not exist in program"

Then I smacked myself in the forehead when I realized that you had ended the comment on the previous line with "..." which I use as the line continuation character in the IDE. It was never getting declared. Now it works. Nice job!

Here's what I have so far for this challenge. I'm trying to stay motivated, but I'm sure you all know how easy it is to get discouraged when you have a ton of things on your plate.

Let me know what you guys think:

Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Jun 2007 00:24
That's pretty funky, Pharoseer! I like. Very tidy coding style you have, too.

Quote: "Then I smacked myself in the forehead when I realized that you had ended the comment on the previous line with "..." "


Ah ... that old chestnut - it's an old favourite in this thread!

Pharoseer
19
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 3rd Jun 2007 02:13
Thanks Ric, it's encouraging to get more profound feedback than "ummm...what is it?" I'm surrounded by people that have little appreciation for mental challenges and think I'm wasting my time. I'm going to try to actually get this finished for the challenge.

Also, the "..." incident reminded me of my Comp. Sci. 2 class back in college. I was always bashing my head against the keyboard over little things like that. Ahh, it does make one feel young again.
acelepage
22
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: Plattsville
Posted: 4th Jun 2007 16:49
Just got back from vacation and am catching up on the forum.

That "..." always gets me. It definitely should be placed at the top of the FAQ list. I always have to remember to do a
Ctrl+H, ..., ., [ENTER]

( 2b || !2b ), that is the question. The answer: true
Ankillito
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 6th Jun 2007 01:32
I have looked back to try and find the current competition, and have got really lost. How about editing the first post to tell where to look for the most up-to-date competition?

Plz?

"There will always be evil, for, without evil, the good shall lose their virtue."
Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 6th Jun 2007 02:51
One page back:

Quote: "
2D Collision Game Challenge
Create a 2D game which includes collision with lines that are not just vertical and horizontal. I will be unimpressed if it is simply a one pixel collision test. The collision must be bouncing, sliding, or both, not just bringing it to a stop. You may use sprites since I know these are fast for Dark Basic Pro, but if you do you should have some kind of pixel perfect collision. Don't just use "if sprite collision".
The game will be judged on game-play and the accuracy of this collision. If you have any questions about these rules just ask.
You have 2 weeks. I will judge on June 9th.
"


Always start on the most recent post and work backwards - most challenges only span one or two pages.

Ankillito
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 6th Jun 2007 05:22
Thx. I tired looking backwards, and ended up on a contest that was scheduled to end in March. That was the first contest announcement I came to. I guess my pet zombie is rubbing off on me...

"There will always be evil, for, without evil, the good shall lose their virtue."
Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 7th Jun 2007 00:49
i've got a REALLY good entry for this =)
it'll be done tomorrow

keep watching!

LongFist
22
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 7th Jun 2007 14:25 Edited at: 7th Jun 2007 14:27
To his Credit, Ric announces the "most recent" Challenge in the mainstream DBPro Forum - this latest can be found here. I'm not sure if there's anything else he can do to make it obvious what the "next" challenge is, though. Anything else might become to cumbersome to maintain. [Yeah, Ric - I've noticed!]

And yeah, I gave it some thought - before the flames come sweeping in from all sides - I'm responsible (at least in large part) for CyberTuna.Net (shameless plug: gamers take note!) and have a full understanding of what it means to have to take care of a Forum system. (As of this writing, we're up to SMF 1.1.2 - and loving it!) And I fully understand what it means to "tweak" it "a little" just to make things "easier". We're (mostly) all programmers here: we know that one person's "simple" tweak is another developer's four-week nightmare, not including unintended "backlash" where those changes have unintended consequences further up the line...

The simplest solution (apart from creating -yet- another message area/bulletin board) is to keep the current system. The thought had occurred to (maybe) make a "Current Challenge" sticky, locked, with a mod (like Ric!) coming in and editing it to reflect the new challenge, as it comes along. But that means more work for Ric, and I'm not too sure I want to volunteer him for any more action than he already has - professional courtesy, if nothing else.

But that's probably the easiest (and simplest) system to maintain, other than leaving things "as is", and just paying attention to Ric's messages in the main Forum, when he posts them.

Hey Ric: Here's a thought - when you post those "Challenge" messages/threads to the general public, could you start the post with "New DBPro Challenge: <whatever>" or something? Just a suggestion - I know what I'm looking for, but some others might not. Sorry - it's not that I don't appreciate what you do - because I do. I do.

Gad. I'm just full of jolly suggestions today, aren't I? Well, I just donned my flameproof suit - surprised that it still fits and all (NHRA regs for top-fuel dragsters, you know...) - so I'm ready for the napalm showers to commence...

LongFist
SuperProgrammer For Hire
ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 7th Jun 2007 22:58 Edited at: 8th Jun 2007 11:12
Here's my entry. Physics are pretty dodgy, but the collisions are at a working level, and they're 100% math based. Forgive the code, it's pretty sloppy. I messed with it alot, and it's all filled with little math notes I made to myself...

Definitely not perfect, but I've spend all the time I care to spend on it.



"Variables won't, constants aren't."
Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 7th Jun 2007 23:14 Edited at: 8th Jun 2007 02:28
@ThinkDigital
The space button clears the visual display of the lines, but it doesn't seem to clear them in the collision system.

@Pricey
Looking forward to it.


And I also posted to let people know that I am still here. I am. Hello. 2 more days.

Insanity is just a state of mind.--- See the SUI
ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 7th Jun 2007 23:48 Edited at: 8th Jun 2007 11:10
Fixed. Also improved the physics a little.



"Variables won't, constants aren't."
Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 8th Jun 2007 10:25
@ Think Digital - not bad at all .... the ball does tend to drop through the lines, but that's probably just tweaking. For some reason, I get the error message 'cannot use reserved word drawlines' - works fine if I just change all references to drawlines to something else. Can't think why that would only affect me and not you though!

@ Longfist - I'll remember to label future challenge announcements as such! Btw - on your recommendation, I just bought Reason a couple of days ago .... great package!

ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 8th Jun 2007 10:54 Edited at: 8th Jun 2007 11:09
Quote: "the ball does tend to drop through the lines, but that's probably just tweaking"


Yes. And no. It shouldn't be dropping AT ALL if you have one line, draw left to right. Otherwise... having more than one line stacked will do it - and yes, some small changes would probably solve that - but they'd have to be well thought out. Since mine finds collisions by finding the Y point at which the ball's x position intercepts the line and then finding the line out of all possibilities it thinks the ball ought to be colliding with, it's a little tougher to work collisions, esp. on both sides. It wouldn't be that tough to tweak out except I have no time to work on it, and the deadline is tomorrow. Ah, well. I'm planning on sticking around here a while anyways.

Also Ric, you probably have some DLL that uses the word DrawLines.

edit: Ahh, that's odd. The ball falls whenever it tries to go uphill... that's no good. I had modified that code some and decided not to post it, and my modified code worked fine - I'll go try and dig it up.

edit #2: found it. I didn't fix everything (again, no time) but this fixes the falling problem



"Variables won't, constants aren't."
Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 9th Jun 2007 18:19
okay here is my function....

i don't have time to write it into a program
but i'll explain the parameters...



check(x1,y1,x2,y2, px, py)

x1, y1, x2, y2 are the co-ordinates of the line
px and py are the player's position

it does work
just not very well for sliding collision

the way it works is, it rotates the line around its starting point, by however many degrees it needs to to make it straight. and then moves the player, around the same point, by the same factor it needed to rotate the line to make it straight

voila we have a straight line, and a player which is positioned in exactly the same place, relatively to the line, as it is to the slanted line!

it then just checks the rotated player against the now straight line, when the player hits the slanted line, he also hits the straight line at exactly the same time!

i dunno if this is how its done in the real world, or if any one else has tried this, but i thought it was cool...

Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 10th Jun 2007 07:09
Well it's still June 9 here (well, it was when I started writing this), time to judge.

Ric- Good code to detect colliding lines. Not really a game.

Diggsey- Especially good for an early entry. The different modes made it interesting. I liked being able to move the screen with the right mouse click.

GadgetFreak 66- Not really an entry, but good job on improving Ric's code.

Enderleit- You're about half way to a full astroids game. It's a pity you never put any kind of collision detection in it.

Pharoseer- Well written code. But, ummm...what is it? I think its quite unfinished, but those enemies do look interesting (and complex for no media).

ThinkDigital- Another good line rider game. Yours was easy to use, but I have the following two bugs. 1. When the ball is sliding across a line if I draw a line under it, the ball will fall though its current line onto the new one. 2. If I draw a line above the ball it will not go below the screen until it slides across the bottom to somewhere without a line above.

Pricey- That's an interesting way to think of checking line collision. I think the way Ric and GadgetFreak 66 have it though, works faster.


Considering all of this... The winner is...


And the runner up...


Insanity is just a state of mind.--- See the SUI
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Jun 2007 11:25 Edited at: 10th Jun 2007 11:27
YAY!, my second win

Now... what will the next challenge be

edit:
What do people think about a 'Make a game with super-fast gameplay' challenge?

Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 10th Jun 2007 13:51
Nice job Diggsey - your entry was very good.

A 'superfast gameplay' challenge sounds interesting, but perhaps a bit too open ended - at the moment that sounds like you could make pretty much any game at all. How about narrowing it down to a specific genre, or putting some kind of restriction on the entry ....... for example, 'make a superfast shooting game with no more than 50 non-stacked lines of code', or something like that? Now that would be a challenge!!

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Jun 2007 16:02
OK, I've got an idea:

Superfast shooting game, with a level editor

The challenge
Create a game, with very fast gameplay. It must have a level editor built into the game, and should involve the player shooting.

Points
The speed of the gameplay.
The user friendliness and customizeability of the editor.
How fun to play the actual game is.

Deadline: 2 weeks from now. (24 June GMT)

Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 10th Jun 2007 20:16
that sounds good apart from the bit with the editor :/

i'm really into random mazes at the moment
and i've got some cool code i could implement in this

flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 10th Jun 2007 20:37
oooh. this seems like its up my next door neighbors ally, ill go spy on him.

nice job man


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 10th Jun 2007 21:03
This should be a good challenge. We'll need a special exception to the no media rule for this one, which allows people to load level data into their game, so long as the level data was created by their level editor.

I'm assuming by saying 'level editor built into the game', it all has to be one piece of code - ie. not a separate level editor for the game, but something like a 'press e to enter editor mode' within the game?

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Jun 2007 21:21
@Pricey
You could still have the random map generator as part of the level editor

@flashing snall
Thanks

@Ric
It must be one piece of code, but you could have a menu, or go into the level edit however you want. That's entirely up to you. The important bit is that it's one piece of code. It should still work fine by just copying and pasting into DBPro. Also, it would be best if the game had a default level built in.

ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 10th Jun 2007 22:04 Edited at: 10th Jun 2007 22:06
oops, missed the next page

"Variables won't, constants aren't."
Pharoseer
19
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 11th Jun 2007 19:34
** Comments on the line collision challenge **

Awesome work everyone. I've been unable to work on mine since my first post, but thanks very much for the feedback.

@Ric -- "drawlines" is a reserved word in BlueGUI, so if you have BlueGUI installed, you would have to rename the custom drawlines functions in ThinkDigitals project.

@Daemon -- it was intended to be an old-school style scrolling shooter. The little satellites orbiting around the various shapes are intended to be missiles that the alien ships fire at you. The "bar-bell" alien ships would just tangle you in their center beams. I figured that if I could get collision working (in the manner defined by the challenge) on those complicated shapes, then I would have seriously accomplished something.

Unfortunately, I've recently been pulled away by other responsibilities (and a few idle distractions). Even though I didn't finish it in time for the challenge I'll do what I can to finish this little project and make it available to the group here. It might take a bit of time (and I might have to borrow someone's collision code to make it work), but I'll get it finished. In the meantime, if anyone sees something they like from my code, feel free to plagiarize, cannibalize or whatever. I'm here to learn, but if I can teach in the process then great.

~Pharoseer
flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 11th Jun 2007 22:41
oh god, school ends tommorrow, and so im being sucked into my computer with all my free time.

btw, anyone evr play frets on fire, great game.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Ankillito
19
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 12th Jun 2007 07:23
I have pity for you. I've been out of school for a week and a half!!

"There will always be evil, for, without evil, the good shall lose their virtue."
flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 12th Jun 2007 19:53
aw, lucky.

just to check, there is no limit to the size of ur code right?


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 12th Jun 2007 21:03
I just got out today!

And there's no limit to the size of your code.

Insanity is just a state of mind.--- See the SUI
flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 12th Jun 2007 21:12
muwhahhaha, cool. so now that i actually know the contest is goin n, i can spend my whole life on it for the next week and half. witch means, its gonna be long most likly, very long.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 13th Jun 2007 00:15 Edited at: 15th Jun 2007 22:48
Well, here's what I have so far:

Sorry it doesn't have any built in levels, but I've attached the one I've been using for testing.



Arrow keys move.
Clicking does stuff.
AI currently is random movement.

O, and I'm going to speed it up later.

flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 13th Jun 2007 01:13
nice.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Ric
22
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 13th Jun 2007 02:04
That's a very good start Daemon - quite a bit gone into it already. Sliding collision with the walls, rather than just stopping, would be a nice addition.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 13th Jun 2007 19:22
Very good!

A few thongs you could improve:
- Make it more fast paced
- Make it more challenging
- Sliding collision

MikeB
19
Years of Service
User Offline
Joined: 5th Apr 2007
Location: My Computer, Shropshire, England
Posted: 15th Jun 2007 10:26
*checks time remaining for DBP trial*
THREE DAYS.


So, now I've got to find £50 .

This challenge sounds great though, I look forward to seeing what people do.

E.D.


Shame I can't change my name
gadgetfreak 66
19
Years of Service
User Offline
Joined: 26th Sep 2006
Location: Kulin,WA, Australia
Posted: 15th Jun 2007 17:18
Just got back from a school camp, which unfortunately stopped me from entering that last challenge. Oh well. Maybe I can get something in for this one. Has anyone here ever played Torus Trooper? It's one of my favorite lunch-break games, and the later levels are definitely applicable, the speed you are traveling at is so insanely fast it's a struggle to stay in the track, let alone shoot anything. http://www.asahi-net.or.jp/~cs8k-cyu/windows/tt_e.html

Daemon
20
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 17th Jun 2007 17:46
Well I'm moving. I'll still be on the forums- but not for a couple of weeks.

Anyway, I can't be judge for the next competition so don't judge my entry please. Atleast don't make it winner or runner up.

flashing snall
20
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 18th Jun 2007 01:43
oh drat, my computer broke.... i cant finish. at least not in time.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 19th Jun 2007 22:33
Hmm. I might have enough time to throw something together for this one. I'll go see what I can come up with.

"Variables won't, constants aren't."
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Jun 2007 12:33
The deadline is tomorrow, so hurry up and post your entry before it's too late!

Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 23rd Jun 2007 17:04
mine is very almost done!

just a few collision bugs to sort

ThinkDigital
20
Years of Service
User Offline
Joined: 18th Aug 2005
Location: A galaxy far, far away...
Posted: 23rd Jun 2007 23:45 Edited at: 24th Jun 2007 05:59
All right, here is my 1000+ line entry - Got REALLY carried away with the graphics

You get killed easy, trust me.

Game
Arrow keys to steer
Space to open fire

Level Editor
Click to place wall
Click-hold to stretch
Right-click to move

Bugs: the walls, in the actual game play, are almost just decoration - collision is crummy, to say the least. Known level editor bugs fixed

However, I made this all in the past 2 days, so I'm a little rushed and I'm busy for the remainder of today, so this is what I'm giving you.

edited - did manage to fix some bugs in the level editor and game


"Variables won't, constants aren't."
Pricey
23
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 24th Jun 2007 15:24 Edited at: 24th Jun 2007 22:54
here it is!

it says there are 5 levels included but there is only one, because i have to go out soon and don't have time...



Game controls:
arrowkeys move
control key fires lasers

Game instructions:
move around and pick up the blue gems
avoid getting shot by the robots and shoot them with your lasers
pick up the keys (grey blocks) to open locked doors

Editor controls:
arrowkeys move
number keys 1 to 7 pick an object
the objects are:
1 - wall
2 - floor
3 - gem
4 - enemy
5 - player's start position (i recomend you only place one)
6 - key
7 - locked door
save with ENTER
delete objects with SHIFT
quit to menu with BACKSPACE

i have enclosed the one level i managed to make
you will need to place it in the same folder as the code obviously

enjoy!

Login to post a reply

Server time is: 2026-07-17 14:08:06
Your offset time is: 2026-07-17 14:08:06