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.

Newcomers DBPro Corner / An educational challenge to all new DBPro learners!

Author
Message
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 17th Apr 2011 03:09 Edited at: 17th Apr 2011 22:16
Hi new guys! Welcome to DBPro and our little community of programmers.

Over the last few months I've been helping several people build their budding programming skills, a couple of whom are learning to develop in DBPro. In my experience teaching people to code, I've found that many people want to jump directly into writing their very first Call of Duty or World of Warcraft clone. It's difficult sometimes to make an enthusiastic learner realise that making a game of such magnitude is not something a week-one learner is capable of! One must start the journey of becoming an epic codemonkey in the same place all journeys start: At the beginning.

So, I started challenging my padawans with little programming assignments, involving concepts that I know they do not yet fully understand. In order to complete the project, they have to acquire fundamental programming knowledge, practical command usage and basic logical accuity that makes them "think" like a program does as it's executing. By the time they've completed the project, they've learned a new structure, command set or logical process that is required in the course of creating games.

I've decided to set one of my favourite challenges loose upon the world of up and coming DBPro aspirants to see if people find it a useful learning tool. To some, it may sound like a very simple and pointless "That's Beneath Me!" assignment, but there's much more to this challenge that it may seem and in reality most of my padawans fail horribly on their first attempt.

I want to see how you fare! If your existing knowledge fails to provide a quick solution to the problem, then by figuring out how to solve it you will have learned some of the basic essentials to game making.

Here's the assignment... The completed program will:

1) Create a swarm of 'bees' whose movement can be controlled by the mouse. Each bee will be a three dimensional cube (or, if ambitious, any small 3D model as imported from any relevant data file), and the swarm will be tightly clustered as if swarming around the mouse cursor and following it around. The formation of bees must be in a random dispersal in three dimensions and number no fewer than fifty.

2) Feature a background image for the bees. An image file must be used for this, containing an image that is smaller than the size of the program window. The image must be resized by the code itself to exactly the correct dimensions to fit the window.

3) Play a different sound each time the left mouse button is clicked. No fewer than three unique sounds should be utilised. The sound must not play more than once per click (no "thousand-sounds-a-second" outcomes).

4) Produce background music in MP3 format that will continue to play after the end of the song.

5) Terminate when the user presses the F1 key. Termination via use of either the ESCAPE key or the X button in the caption bar is to be prevented.

6) Not use any commands from the following 'prohibited' list: CLS, GOTO, GOSUB, LOOP MUSIC, LOOP SOUND.

The following is a link to a ZIP file containing my solution to my own challenge. The source code is not included (I can't give away the answers!) but you can run the executable and see an example of the expected outcome.

http://www.ausleague.com/files/DBPChallenge/Bees.zip

Once a few people have attempted (and hopefully nailed!) the challenge, I will post the source code I used to create this executable so you can see how I did it each step of the way. I'm looking forward to the day when somebody finds a better way to do it than I did!

*** BROWNIE POINTS: Awarded if the program makes use of a User Data Type for an array containing the bee locations.
*** BROWNIE POINTS: Awarded if the program adds a second image somewhere on the screen that the bees can hide behind, while remaining in front of the background image.
*** BROWNIE POINTS: Awarded to anyone who can identify the song I've used as my background music in my example solution!

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 17th Apr 2011 13:05 Edited at: 17th Apr 2011 13:08
This is absolutely what i was looking for. I think this might be a little above my level at the moment as i have only been programming for a couple of months (i have never coded previously in anything, i only learned what a for loop is 7ish weeks ago). And i have not yet tackled anything 3d other than making boxes.

However i would love to at least attempt this and see how far i get (as i dont think i will be able to do all of it). Especially if it will teach me some core concepts that are needed to make a playable game someday as i am under no illusions about making WOW or COD after a week, i know how hard it must be just to make something simple and playable and thats why i am here on this long journey. I had just hit a wall recently and had no where to go to get more skills but this looks like it could be fun.

Slightly off topic: Your game in your sig is pretty much what my current end goal is for now, i would hope to make something like it someday. So if things like this help i will be watching your threads closely. Thank you for doing this.

Let the coding begin.

Edit: YES!!!! I knew i heard that song before. Its from total recall im sure of it because i love the old Schwarzenegger films, though i seem to remember the original being slightly faster for some reason but maybe i am wrong.
Koded
13
Years of Service
User Offline
Joined: 15th Apr 2011
Location:
Posted: 17th Apr 2011 13:15
Certainly above my current skill level, however I'm going to print this out and pin it up.. I'll build it as I go (hopefully!) lol.

Thanks Agent.

Mostly fail... sometimes epic
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Apr 2011 16:54 Edited at: 17th Apr 2011 16:59
Altho I'm far from a n00b, I thought I'd have a quick go at this.

It took me around 3 hours to complete. And I did it using a clean install of DBP 7.7 with NO PLUGINS (Which was a bit of a struggle, lol)

I used the same samples/music as Agent provided, but I made my own graphics (such as they are, lol, I'm a coder, not an artist!)

Agent, if you add an email address to your forum profile, I'll email you my source so you can have a look.

Having said that, I'm now going to look at Agents example and see how mine compares to that

>Download Bees by Prof<

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 17th Apr 2011 22:07 Edited at: 17th Apr 2011 22:44
Somarl wins the first Brownie Point for identifying the song! I liked the track so much I ripped it straight out of the movie DVD and looped it to make it longer. TR is one of the greatest movies of all time, is it not!

Even if you can't make the entire project just yet, each individual requirement is designed such that it can be completed independently of the others. If you don't know how to make the bees just yet, see if you can get the looping music going without using LOOP MUSIC, and get a different sound playing with each mouseclick. Add the bees when you've figured out how.

This particular challenge will, if you attempt it seriously, step you towards the skills you need to make games by teaching you about arrays, UDT's, media (images, sounds and music), input control from the mouse and keyboard, and taking your first steps into controlling 3D objects within the screenspace. All of these things are essential in game creation, which is why I like this challenge so much.

Now to assess Prof's submission! Starting with zero out of a maximum of ten possible marks:
+2/2 (2/10) for making bees that follow the mouse cursor. (Task 1)
+1/1 (3/10) for the background image that is resized by code and stays behind the bees. (Task 2)
+2/2 (5/10) for left click sounds. (Task 3)
+1/1 (6/10) for repeating background music. (Task 4)
+1/1 (7/10) for terminating with F1 and preventing termination with ESC or with the close window button. (Task 5)
+1/1 (8/10) for making an image that the bees can hide behind. (Bonus Task)
+0/1 (8/10) for using a UDT-based array to track the bees. (Bonus Task) - Witholding this point until I know he's done it this way!
+0/1 (8/10) for identifying the song I used in my sample solution. (Bonus Task) - this point is no longer possible to get as Somarl got it!

Bonus assessment marks:
+1 (9/10) because his bees are cooler than mine (they actually swarm when the mouse isn't moving)
+0 (9/10) for not using plugins - you don't get any bonus points for not cheating! (lol)
-1 (8/10) because the bees aren't clustered in or moving in three dimensions - this was a required factor! Padawans must learn to work in three dimensions if they are to become Jedi.
-1 (7/10) for taking three hours to do it! Because they're supposed to be learning, padawans don't lose a mark for taking a long time, but Jedi do!
-1 (6/10) You lose one more mark so that the padawans can get a better score than you and laugh at you

FINAL ASSESSMENT MARK: 6/10 for Prof!

NOTE: I was about to subtract one mark because I don't get a sound play *every* time I click if I am clicking rapidly. However, on reexamination I realise he's stopping soundplays if the last sound hasn't finished playing yet. So he gets his mark back because this is smart

Come along now, padawans: The first submission to score better than Prof gets an additional bonus mark for beating a Jedi at his own game

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Apr 2011 22:41
@Agent:
I don't want to post the source for it here just yet, until a few other ppl have tried. But I will email it to you if you add an email addy to your profile (or just email me on mine)

But my bee's are 3d! Most of the time spent making it was sorting out the 3D bee movement! (Altho you possibly can't see it coz the are so small. Watch the rotation of them, they turn and move on all 3 axis)

Also I am using a UDT to keep track of the Bee co'ords

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 17th Apr 2011 22:47
Heh, I've been editing and revising my last post to turn it into a more or less standard "marking sheet" so everyone gets judged by the same standards.

Keep the source to yourself for now. I'll take your word that you're using a UDT but I'm still making a suspicious dubious mean face about the 3D movement of the bees... I'll let the padawans vote to decide whether you get the point for it

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 18th Apr 2011 00:00 Edited at: 18th Apr 2011 00:01
Hey I'm working one up too, I've just been slowly moving into 3D recently and this challenge gives me more reason to exercise blender and the 3D statements. I'll post it up very soon when I'm done with it.

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 18th Apr 2011 06:08 Edited at: 18th Apr 2011 06:12
Ok here's my entry. I think I hit all the points.

- Bee follows mouse around, 50 of them.
- Bee moves in random 3 dimensional directions.
- Background image.
- Foreground image covering Bees.
- Looping music not using Loop Music statement
- 3 random unique sounds with left-click.
- F1 to exit disable the use of esc/X button.
- Use of only functions and no goto/gosub.
- Use of UDT array.

I also included my blender model. The mp3 is also the same one being used in the DARKNOOBs - SpaceInvader project.

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 18th Apr 2011 21:58
An excellent submission from another Jedi, Ashingda! Here is the marking sheet I am giving him:

+2/2 (2/10) for making bees that follow the mouse cursor. (Task 1)
+2/2 (3/10) for the background image that is resized by code and stays behind the bees. (Task 2)
+1/1 (5/10) for left click sounds. (Task 3)
+0/1 (5/10) for repeating background music. (Task 4)
+1/1 (6/10) for terminating with F1 and preventing termination with ESC or with the close window button. (Task 5)
+1/1 (7/10) for making an image that the bees can hide behind. (Bonus Task)
+1/1 (8/10) for using a UDT-based array to track the bees. (Bonus Task)
+0/1 (8/10) for being the first to identify the song I used in my sample solution. (Bonus Task)

+1 (9/10) for having cool swarming bees like Prof did.
-1 (8/10) for not making the music repeat when it was finished (this was a required element of the challenge!)
-1 (7/10) for not making the bees have santa hats and because all Jedi are losing a point for random reasons so that padawans can get better scores than them

FINAL ASSESSMENT SCORE: 7/10 for Ashingda!

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 18th Apr 2011 22:24
i do wish the pros would stop competing, they are making me look like crap.

Unfortunatley I cant even do the challenge i am afraid, and have failed my first task as a padawan. I thought i would have a bash, but after a long long time of mulling over code and chopping and changing things i am unable to complete 90% of what is required. I still have a lot to learn if i am to complete my Jedi training im afraid.

I did enjoy rolling my sleeves up and giving it a go but it has put me down a little as i really wanted to do it.

I will keep on learning what i can and hopefully i can come back to these challenges you will be laying out and give them a proper go. At this moment in time i just do not know enough. Was fun though, i made a little bee in blender No where near as good as Ashingdas animated bee, but it only took me a few minutes after i first read this thread so i was chuffed with the results from what i put in considering i didnt know what a vertex was 2 months ago. I hereby name my little bee, Gerald.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 19th Apr 2011 01:44
@Somarl
You'll pick it up if you keep at it, we've all been through that too. Been times when after long hours, days, even weeks trying to get something to work eventually it clicks and along the way you picked up a ton of other useful skills.

I'm still quite noobish myself, still got a long way to go.


@Agent
Darn, the music was too long so I didn't even bother to wait for it to end to test it. I had thought the code would work but sadly it did not LOL.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 19th Apr 2011 10:01
Yeah, i am going to keep at it but again ill just have to take a bit of a step back and not compete in the challenges for now. Still going to see if i can work on making randomly placed objects work with the mouse though. I reckon ill be able to get that in the not so distant future, just not in any decent time frame to be part of the challenge.
Keep them challenges going though! I want to be a part of one of them at least
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 19th Apr 2011 13:52 Edited at: 19th Apr 2011 16:15
Hey Somarl,

If this one is a little above you then that's ok, there is quite a lot of stuff in this challenge. It's certainly not a simple task for a new learner.

If you are getting stuck you are allowed to ask questions and I will guide you in the right direction. This isn't really a "test", it's supposed to be a guided learning experience. You can post here or in another thread, and I will help you with whatever is getting in your way.

Otherwise, there will be other challenges - both more complicated that this and more basic than this. I only started with this one because it's one of my favourites as it teaches almost all of the core gamemaking skills (moving 3D objects on the screen in response to user input, media like images, sound and music, arrays and loops).

Bear in mind that I have no expectation of padawan's submissions being like the two Jedi submissions. Those are the product of experience, while the example I produced was designed to look like what I expect padawans to produce. Making the bees actually swarm isn't necessary; that's far more advanced. All you need are objects that respond to the mouse.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 19th Apr 2011 18:13
Well some of the things i was having problems with was making an object follow the mouse as making object movement coincide with mouse cordinates does seem quite above me at the moment. I put everything down and went to work on just moving a simple box along with the mouse but nothing i have tried yet (including things like point object - which is a horrible command to use with the mouse) works. Ill keep on having a play around and see if i can come up with something but until i get that box moving properly there isnt much point in doing a bunch of objects, i wouldnt know where to begin in making them all move relative to their last position in accordance with where they were against the old mouse position.

Also i cant make the sounds play properly without adding a wait command which is undesirable as it freezes the whole program till its done, so ill read a little more when i get back see if my hands on book has anything about it (it does have a sound and music chapter but i skimmed it.).
Also making the music play is a bit tough without using loop as my therory revolved around making a timer that was the length of the music, when its done, play the music again but i dont know how to do anything with timers yet and everything i have tried hasnt worked so ill read up a little more on timers after that.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 19th Apr 2011 19:22
@Somarl:
I think maybe the Help Files will give you more help, you should read all the commands in the "Music" section of the help. There is no need for a timer, you just need a way of checking to see if the music is playing or not [hint]

The same can be said for the "Sound" commands.

The following the mouse bit is trickier, so I will throw a bone here.

Quote: "PICK SCREEN
This command will calculate a relative 3D coordinate from a 2D screen coordinate. "


Hope that helps

(And I hope I'm not treading on any toes or spoiling the challenge with these hints, apologies if I have Agent)

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 20th Apr 2011 01:41
I managed to have a large amount of time to play with this today prof so thanks for the info.
I looked at all the commands and put the bee project to one side and just worked on moving a box around (keep it simple) with the mouse. Unfortunately i was unable to do it as i struggle getting real co-ordinates to re position the object, and as far as i know there are only 2 ways of moving an object. Move object and position object. Both which work a little strange for a newcomer to fathom.

I made a nice little function (a very simple one) to work out whether the music was playing or not using a certain command and then when it returned a 0 play the music again. It seemed like its meant to work but doesnt as the command constantly reads 1 once its been played and never reads 0 so the If statement that controls it never says If its 0 then play music. As for the sounds i cant get them to work the same as yours and ashingdas projects but i got half way there. My function that cycled through the sounds did work at first but far too fast, adding the other command in now waits for the whole thing to be played before letting me click again which is not what i wanted, and also the cycle has stopped and it plays the same sound again and again. I looked at it and the logic seems pretty spot on so although its wrong im not going to spot whats wrong with it so ill leave that one for now.

I got all sorts of numbers to come up using all sorts of combinations of Pick Screen, Get Vector, Pick Vector, Object Screen, and Pick Object and learned a little here and there but was unable to apply it to anything relating to the cube and wouldnt know where to begin relating it to 50 UDT objects with different locations.

But all that work today was a nice introduction to a few things i had not seen before. Becoming more familiar with commands like this is what i need to progress so i feel like i have taken a step forwardish at least today.
Wyldhunt
15
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 20th Apr 2011 20:34 Edited at: 20th Apr 2011 20:49
Interesting.
I may be able to find some time this weekend to give this a shot.

I'm no Jedi when it comes to DBP.
In fact, my actual DBP scripting experience probably puts me close to the padawan category.

I bought DBP a few years ago, and then wound up using a different game engine. So, I'm decent at programming and game making theory... Just not in DarkBasic Pro.

I have some ideas though. I'll see what I can get on my day off, if the competition is still going.

This was a good idea.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 21st Apr 2011 23:23 Edited at: 21st Apr 2011 23:30
Somarl,

You should bear in mind that the challenge only requires you to produce bees that are controlled by the mouse - they don't have to follow it like the submissions of the two Jedi. Look at my example - direct control by the mouse, that's all this challenge requires.

I suggest you just make a single bee (cube!) and make it become the mouse pointer. That'll put you in a good position to start.

Your repeating music logic seems to be correct. All you need to do is check to see if the music is currently playing. If it's not, start playing the music! This will be triggered both at the start of program execution to start the music the first time, and also each time the music runs out, to loop it. It requires one single line of code. There's a reason I want padawans to repeat music this way, even though it's easy to use LOOP MUSIC. There are other commands that you'd want to repeat every so often, and they don't have an automatic looping equivalent, so learning how to repeat stuff early on can be useful.

PICK SCREEN is an excellent command for turning a 2D screen position into coordinates in three dimensional space. It is definitely a command worth knowing everything about - but you won't need it for this project unless you make your bees slowly drift toward the mouse, like the two Jedi did. All I expect from this challenge is that you make the bees respond directly to mouse input. They don't have to follow the mouse cursor - they should *be* the mouse cursor.

I have no objection if you post code that isn't working, and we will show you how to correct it. Don't post your entire project though - just show the parts of the code relevant to one of the list of tasks set. Why don't you show me your function that loops the music, and I'll help you towards fixing it.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Apr 2011 14:49
I havent had a play with this for the last 2 days but came back to it after the above post and to be honest, it doesnt look like im going to get any further. What i will do is post everything up once the challenge is over in case i spoil anything. Its not that i cant be bothered trying any more but i just cant make the objects respond to the mouse the way i have drawn them. I have played around with a cube and making it move around with a mouse but there is isnt a way i can think of to make it move the way i want. I am not really positioning the initial bees around the mouse cursor as i dont know how and i dont think thats helping, i was just putting them sort of randomly round the centre of the screeb which is where the mouse cursor is set.

I have however managed to get 2 things spot on from the start with no worries and one thing a bit close. The window not closing on escape or the (x) is good, and the program ends when F1 is pressed, the image sort of works but its not exact as resizing the image cause a very large black gap down the side so i had to offset it a little. Other than that though its good. I will be watching this thread for when the results come out Cant wait to see how people have done it.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Apr 2011 20:49
Ok, so you've got a cube moving around in response to the mouse, just not the way you want. That means is you're successfully polling input from the mouse and that you know how to move an object around on the screen. If it's just not moving in the directions you want, keep in mind that the X and Y coordinates in 2D space translate to X and Z coordinates in 3D space. The Y coordinate becomes depth. Some of your positive and negative coordinate values may need to be reversed, depending on how you use them.

Perhaps if you describe the way your cube is moving, I might be able to help you get it moving the way you want it.

Remember that failure is only a temporary situation. It's giving up that makes it permanent!

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Apr 2011 21:59
If i do this for example

It does not have the desired effect. Bare in mind that this is only for one cube very neatly positioned. For multiple objects at random starting points i have absolutely no idea.
Wyldhunt
15
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 22nd Apr 2011 22:28
That's the same issue that I've been struggling with.
The problem, I think, is that MouseX and MouseY only give the actual screen coordinates. Not the 3d world coordinates.

So, a screen set to a resolution of 800X600 would return
MouseX = 400
MouseY = 300
if the mouse were in the middle of the screen.

The camera may be floating at any point in the 3d world and it may be at any angle. MouseX and MouseY won't change.

So, I did some Googling on the subject.
There are commands to work with such as Pick Screen and Pick Object which can grab the actual 3d coordinate based on where the mouse is located(Or, where the object under the mouse is located).
These return a vector3, but they don't appear to return the final product that we need. The vector appears to be where that location is in relation to the location of the camera.

So... I did more googling.

I found this (Many thanks to Neuro Fuzzy for hosting this on his site)
http://www.neurofuzzydev.com/V/D/index.htm

That is a class on DBP vectors. It walks you through the very base level questions about what vectors actually are. Towards the end, it gets in to how to use pick screen commands and how to work with that vector to get something useable.

I'd start with the very first chapter and just give the entire thing a good read. It's not too long, and it explains how to do these things really well.

As of now, I have a cube that always matches the mouse position. I also have a second cube that tries to chase the mouse around using some of the logic in that tutorial. I'm thinking about trying my hand at a swarming script now, like a couple of the others did.

I'd have never been able to do that without that tutorial.

My only issue right now is that the chasing box only chases in 2d, but I think I can solve that with some dimed arrays... At least, that's my plan.

So, that's my update. I hope to have more time for this tomorrow or Sunday.
None of this is intended to give away answers (More so because I don't have the answers yet). But I figure we'll have a better shot if we share tutorial links and such.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 23rd Apr 2011 11:33
That's the idea

I should note my interest in people's use of vectors and PICK SCREEN. I don't know what technique the other Jedi used but I didn't do any of this for my sample. If you wanted bees to actually swarm towards the mouse like they did, you'd use vectors but the following effect isn't necessary for the challenge. The bees just need to be attached directly to the mouse, and you don't need vectors for that.

However, vectors are a great thing to know about, so if you want to learn about them this will be a good way to start.

Wyldhunt
15
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 23rd Apr 2011 20:23
I can't find any other means of generating an actual 3d location from the mouse location other than pick screen or pick object. Both of those appear to require at least basic vector math.
I'm far enough along with the vector stuff to not want to start over again, but I'm curious how we could find a 3d point from the mouse, and then generate 50 3d offsets for bees without vector math...
At the very least, it seems like you'd need something like
Pick Object to get a XYZ vector(Assuming that you had an object to pick) and then add the Camera XYZ location, which would be basic vector math.
Once you had your 3d point, you'd need 50 vector offsets so that you could add an offset vector to the pick location vector to find a unique position for each bee.

Controlling the swarm movement, which is definitely more advanced, required more advanced vector math. But even the basics seemed to require adding vectors.

Are you willing to give any clues as to what your alternative is?
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 23rd Apr 2011 20:31
I didn't use any vector maths in my program.

My bees fly by randomly changing the x,y,z angles and moving it a set amount forwards.

The only two vectory commands I used were the ones to find out the x and y position of the mouse in 3d space.



Jimpo
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 23rd Apr 2011 20:58
I think you guys are overcomplicated things/misunderstanding the challenge. Based on Agent's own solution, even though the bees are 3d objects, they are still only moving in 2 dimensional space. So only the bees' x and y coordinate are changing in relation to the mouse. The entire bee positioning can be done in a single line of code, with no vector work. So don't over do it

Here's a list of command that may be helpful, depending on how you implement it:


Sorry Agent if I gave out too many hints.

Wyldhunt
15
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 23rd Apr 2011 21:27
But, it would technically be vector math to add anything to the angle vector of your bees!
Even if you did it one point at a time (X=X+rnd(10):Y=Y+rnd(10):Z=Z+rnd(10)), it would be the same as adding Agle Vector to Random10 Vector.

A vector by any other name... (I'm sure you've heard that saying before )

Or did you let DBP do the adding with turn commands and such?
Wyldhunt
15
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 23rd Apr 2011 22:38 Edited at: 23rd Apr 2011 22:51
Sorry about the double post...

@Jimpo
That's where I started at. It sounds like Somarl was also trying to use those same commands.

Here's the issues that I ran in to and why I wound up doing it differently:
Because the bees are 3d, the 2d mouse movement doesn't match the bee movement. It'd work fine with 2d sprites and things of that nature, but it lost cohesiveness when needing a true 3d location.
If I have my screen resolution set to 800X600, I can grab my MouseX and MouseY just fine. They might return something like X=120, Y=90. That's just a screen location and means nothing to my bees in 3d space. If I were running at a higher resolution, that same screen location would return different results because it's just based on screen pixels and not 3d location.
Mouse Move has similar problems. It seems to return screen pixels crossed by the mouse and not true 3d units crossed. If I move my mouse an inch on the screen, I may get Mouse Move X of 40. If I have a higher resolution set, that same inch may return 50. Both times, I'm hovering over the same 3d location.
My bees are all different distances from the camera to demonstrate 3d. If I move them all by Mouse Move X, they won't move the required distance to stay under the mouse because the screen resolution does not match the 3d world units. Especially at different distances.

If I were to make a sprite which gave the impression of 3d boxes, I could move that around the screen just fine.
The problem we're having is how to translate the mousex and mousey in to a 3d world location that could be anywhere in 3d space.

I chose an arbitrary distance from the camera to create my bees(200, I think) and then used pick screen to get the 3d world coords 200 units in front of the mouse.
That was the only way I could think of to translate the 2d screen resolution location in to true 3d space to make a bee.
Once I had that first location which was guaranteed to always be 200 units in front of the mouse, I was able to make my bees interact with that location however I wanted.

So, although they are only moving in two directions, their location is still 3d. and we'll still need 3d coordinates at some point so that we know where to create them at, or where to move them to. Just 'Left' isn't enough if we don't know where they need to start out at or exactly where they are going. Hence the pick screen and vectors.

I'm curious to see the different ways that people have found of doing this...
You should make a quick submission so that we can see how you were thinking of doing it, Jimpo.

With all of that said, I'm still learning the DBP commands, so my understanding of what data the commands return is probably flawed...
Jimpo
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 23rd Apr 2011 23:45
Keep in mind I was only referring to how to do the static unanimated bees like in Agent's example.

You're right that the values from the mouse commands aren't directly applicable to 3d space. You're understanding of what they return isn't flawed, it's right. Can you change the returned values in any way so they mean something in 3d space?

If I posted an .exe, it would just have the same movement as Agent's, and I can't just give away the code. Maybe Agent will post the answers?

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Apr 2011 00:40 Edited at: 24th Apr 2011 00:43
Quote: "Because the bees are 3d, the 2d mouse movement doesn't match the bee movement."


It doesn't have to. The bees just have to be controllable by the mouse. Whether or not they move the same distance that the mouse did is not a part of the challenge. Technically, they don't even have to move in the same direction (though that is the idea). They just have to be controllable by the mouse.

At no stage in my solution do I convert any 2D locations into 3D ones, or concern myself with the third dimension in any way other than the initial positioning of my spheres.

You will need to use MOUSEX() and MOUSEY(), but none of the other commands suggested above are necessary.

Vectors are cool to know about, but you don't have to touch them to solve this challenge.

Perhaps by declaring an array (possibly a UDT-based one?) full of random bee positions, you could draw a swarm of bees in some arbitrary location on the screen. Perhaps you could find some way to modify these locations based on the return values from MOUSEX() and MOUSEY()? A clever padawan might even venture into the third dimension by addressing MOUSEZ(), too...

Or maybe there are other ways!

EDIT: If using the mouse for input is getting under your skin too much, why don't you submit something in which the bees respond to input from the cursor keys? Once you've got that working, we can talk about bringing the mouse into play.

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Apr 2011 03:01 Edited at: 24th Apr 2011 03:35
You have to think outside the box a bit, there is no one-way to make something, there are always alternatives. Radix is one of the fastest sorting algorithm but does it mean it should be use for every program? Absolutely not! It uses a lot of resource and works better for numbers rather than words.

There are hundreds of different ways to get the same results and it's up to you to figure it out so be creative but also remember to keep it simple as can be. Programing isn't magic, things don't just pop up when you want it to. You have to trick the machine to do what you want the results to turn out like.

I hope I'm not giving away too much with this... It's only 8 lines and can become 6 lines at the very least.


Arcmage
14
Years of Service
User Offline
Joined: 20th Apr 2010
Location: Pluto
Posted: 24th Apr 2011 21:13 Edited at: 25th Apr 2011 02:51
My solution is significantly less gigantic than the ones above but I am much more noobish. I believe it satisfies all the requirements of the challenge.

Edit: Oops accidentally attached source file. Removed it in second attachment. Btw how should I send you the source so you can see the UDT?

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 26th Apr 2011 07:27
Hey Arcmage!

Thanks for your contribution. Here's your assessment:

+2/2 (2/10) for making bees that follow the mouse cursor. (Task 1)
+2/2 (3/10) for the background image that is resized by code and stays behind the bees. (Task 2)
+1/1 (5/10) for leftclick sounds. (Task 3)
+1/1 (6/10) for repeating background music. (Task 4)
+1/1 (7/10) for terminating with F1 and preventing termination with ESC or with the close window button. (Task 5)
+1/1 (8/10) for making an image that the bees can hide behind. (Bonus Task)
+1/1 (9/10) for using a UDT-based array to track the bees. (Bonus Task)

FINAL ASSESSMENT MARK: 9/10 for Arcmage!

I'll trust your word that you used a UDT, and I'll even give you the mark for the leftclick sounds, even though you've played them on rightclick instead. I suppose maximising the window and preventing resizes prevents the user from quitting with the X button, so you get the mark for that even though I was rather intending for people to selectively remove the X button from the window

Well done!

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 26th Apr 2011 14:24
I've been glancing at this thread for a while now and would love to attempt this challenge but unfortunately I just don't have enough time on my hands, just not enough hours in the day.

@ Somarl
One of the reasons you may be having trouble with the code you posted, this one:

is that it could be a possible bug in DBPro. There is a possible problem with using mousex and mousey in conjunction with position mouse command. This snippet has been reported in the DBPro U77 RC thread, there is a slight inconsistency with the reported mousex and mousey commands and the coordinates used in the position mouse command:

But this hasn't stopped others so you should be able to complete this challenge as well. Just keep trying

A clever person solves a problem, a wise person avoids it - Albert Einstein
Arcmage
14
Years of Service
User Offline
Joined: 20th Apr 2010
Location: Pluto
Posted: 26th Apr 2011 23:26
Thanks for the score.

Btw to the other contestants I did not use pick object or any other fancy technique just MouseX() and MouseY() and a little math and logic.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 28th Apr 2011 23:00
@Hodgey, oh thanks for that, i wasnt aware of it. I see that that was not quite the right path anyway because other people have attempted and succeeded without using that so i should hopefully be able to work something else out.

Ive been a bit busy the last week as my dad had a heart attack but is getting better, but ive been running round like a bit of a madman so completely neglated everything else bar work, however i hope that i can get back on this and get focused and see if i can submit something soon.

Math and logic (although essential to programming) are not my strongpoint so very often the simplest solution staring me in the face will be completely overlooked in favour of complicated methods that dont work. Ill continue to work on just moving a single box around first and if i get it ill try a few boxes, if i can get that working i can make my blender drawn 3d bees work the same way with ease i should imagine.
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 1st May 2011 11:17
Hi Somarl,

Yes I think that is the best way for you to proceed. You might want to start by making the box respond to keyboard input using the cursor (or any other) keys, and then chop up your code and switch to making the box respond to mouse input. You may find one easier than the other!

As ever, return to us if there are problems and we'll guide you along the way

jaccar09
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 1st May 2011 13:15
hi, i'm new here and pretty much a beginner in DBPro. attached is my take on this. i wanted to have an effect like the first submission here though i don't know how to do that, haha. so i pretty much just used what i have already learned before.

i'm not sure about my title bar, it's not supposed to be there but i can still see it... but you can't exit with the exit button anymore though i kinda got away with adding some simple effects with my cubes...

Attachments

Login to view attachments
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 1st May 2011 15:00
Hi, great thread! This is exactly what we newcomers want and need.
I've attached my entry and i've done my best to meet all critera however, the user data classes are giving me a headache so I figured Ill hand this in as is and continue work on mastering user classes.

great choice of material, I had some real head scratcher moments(more like hours) and it was a perfect challenge for a beginner. greatly satisfying and educational.

I hope it doesn't matter that my bees, move on an xz plane rather than your xy. I just thought it better suited the theme of my entry.

look forward to your future challenges.
thanks man
kezzla

Sometimes I like to use words out of contents

Attachments

Login to view attachments
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 2nd May 2011 16:31
Hey guys! Good to see new guys coming through with submissions. I'm glad you think these are useful challenges.

Here is an assessment for Jaccar's submission:

+2/2 (2/10) for making bees that follow the mouse cursor. (Task 1)
+2/2 (4/10) for the background image that is resized by code and stays behind the bees. (Task 2)
+1/1 (5/10) for left click sounds. (Task 3)
+0/1 (5/10) for repeating background music. (Task 4)
+1/1 (6/10) for terminating with F1 and preventing termination with ESC or with the close window button. (Task 5)
+0/1 (6/10) for making an image that the bees can hide behind. (Bonus Task)
+1/1 (7/10) for using a UDT-based array to track the bees. (Bonus Task)
+0/1 (7/10) for being the first to identify the song I used in my sample solution. (Bonus Task)

FINAL ASSESSMENT MARK: 7/10 for Jaccar!

Note that you didn't get the mark for repeating background music as the program crashes when the music ends instead of starting the music again. The error I'm receiving is Music Does Not Exist At Line 135. See if you can figure this one out.

I've also given you a mark for using a UDT based array for your bee locations, giving you the benefit of the doubt even though you didn't state one way or the other whether you did this.

You also got a mark for preventing termination by clicking the close button in the caption bar. You don't seem to have done anything to hide the close button, but despite several attempts I couldn't find a way to actually click it, so you got the point

Good submission!

Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 2nd May 2011 16:57
As for Kezzla's submission, I'm afraid I was unable to test it as I can't run it due to the 16bit/32bit windows problem. If you email me your code, I'll compile it in the correct manner for my system and assess it

Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 2nd May 2011 19:45
Hello guys !
I started working on this today and for now, i managed to make:

-bees following my mouse
-ending the game only by F1
-playing sounds with mouseclicks

but, i have a problem with looping music.
Here is my code snippet:



I tried to do the same but with sound, not music, and it worked.
Could someone please tell me why this won't work.
Thanks !
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 2nd May 2011 21:13
Exactly the same problem i had, really dont know why this doesnt work but it seems that your music playing will never equal 0 even when the song has stopped. Could be a bug or something else we missed but this is exactly the way i did it and it didnt work for me.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd May 2011 21:20 Edited at: 2nd May 2011 21:38
Hmmm, Thats odd. I'm almost 100% certain I used the same code in mine (altho I possibly didn't listen to the end of the song, I just assumed it would work)

(I'm just gonna run off and test this)

Are you all using the latest version of DBP? (7.6 stable, or 7.7 rc 7)

>Edit<
Yup, This definately looks like a bug, does anyone know if it's been reported yet?

Even weirder...

This doesn't work...


where as this almost identical code, but with a few diagnostics thrown in does...



Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 2nd May 2011 21:38 Edited at: 2nd May 2011 21:44
Hmm, I'm not sure wich version I use but when I go "Check for updates it says it's up to date.

>EDIT<
PROF, I just tried your program and the music loops just fine.
Could you post a snippet on how you made it ?
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd May 2011 22:06 Edited at: 2nd May 2011 22:07
@Matija the n00b:
Easiest way to check would be to use the "About" from the Help menu in the Editor. Should report DBPro Version there, although it'll say "1.076" for what we call 7.6, or "1.077" for the 7.7 beta test version.

>Edit<

I already posted 2 snippets in the post above this one, one works, one doesn't altho the code is pretty much identical.

Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 2nd May 2011 22:08
Hm, it says 1.071 , how do I update it ?
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 2nd May 2011 22:11 Edited at: 2nd May 2011 22:13
go to...

http://www.thegamecreators.com/?m=view_product&id=2000&page=upgrade7-6

and download and install the update

The 7.7 beta version of the update is stickied at the top of the DBP forum until it becomes official.

Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 2nd May 2011 22:37
OMG, I just lost all my code .

I saved it and all , but now when i try to open it, its empty.
I still have my application but all the code is gone.
Also all the other programs work, just this one.

I guess I'm out of challenge haha, I just don't have patience to write it for the third time, I'm just so pissed of right now.

But the good news is that i managed to update it

Login to post a reply

Server time is: 2024-11-22 12:58:23
Your offset time is: 2024-11-22 12:58:23