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 / random cube spawn help...

Author
Message
aarrowh
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 11th Mar 2009 02:29
I was testing a theory for a game, while trying to get some practice with for-next loops, but what I'm trying isn't working...

I'm trying to randomly spawn 100 cubes onto the screen. The first cube comes up fine, and in a different spot every time(although sometimes out of sight, don't get that either....) but it won't make more than 1 cube...so i was wondering if anybody could give me some help here.

the code.






Image thanks goes to AndrewT
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 11th Mar 2009 02:51
It does create 100 cubes but places them all at the same place - start your for next loop before generating random coords
aarrowh
16
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 11th Mar 2009 03:35 Edited at: 11th Mar 2009 03:36
Thanks, it works now. But the cubes only appear in areas on the upper right hand side of the screen and I can't see all of them...I tried adjusting the camera position but it didn't change anything...any ideas?

*edit*

I also would like to apologize for starting a new thread...forgot that the sprite question one was still up here, should have asked there.



Image thanks goes to AndrewT
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 11th Mar 2009 04:01
We'd have to see the new code to know for sure, but I'm guessing you are only positioning the boxes at positive positions. Try something like this to get both negative and positive values:

x=rnd(10)-5
y=rnd(10)-5
z=rnd(32)-16




James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 11th Mar 2009 04:37
Its up to the coder to control the camera, the simplest way is to use "control camera using arrowkeys" command in the main loop.



There is an example in the helpfile but it doesn`t work as is for "control camera using arrowkeys" example. I wrote to Lee once highlighting this - I attempted to get it to work the way I thought it was intended to so Lee did some alterations(I had made some heafty mistakes!);


Thought you might find it of some help in the future - just like the helpfile example it deals with multiple cameras but also shows control camera with arrow keys use

There are other ways to control the camera. Do a forum search for mouse look, camera control, fps, 3rd person, freeflight and that sort of thing

Login to post a reply

Server time is: 2024-09-28 02:29:41
Your offset time is: 2024-09-28 02:29:41