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 / Camera help

Author
Message
Databug
16
Years of Service
User Offline
Joined: 27th Oct 2008
Location: Elsewhere
Posted: 30th Nov 2008 23:28
Hey, i'm trying to make the camera follow this 2d sprite, but it won't.
I have a DarkBasicPro guide but it appears camera commands only work on 3d objects.
A little help?
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Dec 2008 05:48 Edited at: 1st Dec 2008 05:59
people tend to use the term 'camera' in 2d but there's no real camera at all (atleast in dbpro terms).

basically, you, the programmer, manage what your player sees in 2d or 3d, right? we call this 'camera work', in general.

here's ONE example of some 2d 'camera' work. it's very basic, but you'll get the idea. use the arrow keys to move the player (a red square) around a randomly generated map. note the illusion of player movement, and the camera following it



you can do some fancy 2d 'camera work'... world rotation, simulated "3d movement" into and out of of the screen, etc. but for now, just trying to show you the concept of a 2d 'camera'.

good luck!

edit: and, yes. the coding is not efficient (i paste all images whether they're 'visible' or not, etc) and is very basic (ie, you wouldn't want to paste this into your project!) but you'll get the idea.

check the code snippets and code base for better examples!

Virtual Nomad . California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium
Databug
16
Years of Service
User Offline
Joined: 27th Oct 2008
Location: Elsewhere
Posted: 3rd Dec 2008 04:23
Ah i get it. Hmm, thats alot of moving for what i have in mind

so, in that reasoning, id have to move all of my background, enemies, etc. when i use the arrow keys just to get the impression that the "camera" is following the main character?

thnx a bunch!
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Dec 2008 09:03
not an expert at all on sprites or movement but could try something lie this

just ad a variable to your background and sprite position
sprite 1,x+c#,y+b#
if uparrow=pressed b#=b#+1
if down arrow=pressed b#=b#-1

so just buy adding a variable to each sprite background pos. ect
any time you hit a directional key everything moves in sync
don't copy paste my syntax is vry wrong but hope u get the idea

A child's dream never dies.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 3rd Dec 2008 09:38
Here, hope this helps just typed it up.



Don't know if the code will work as is did on mine dbpro but others seem to have problems with it sometimes just load your images background and a character and see how it works change the image commands to where they work for u ect.

A child's dream never dies.
Databug
16
Years of Service
User Offline
Joined: 27th Oct 2008
Location: Elsewhere
Posted: 5th Dec 2008 05:14
Aha, got the hang of it.
See here
http://forum.thegamecreators.com/?m=forum_view&t=141043&b=7

thnx all

I like pi

Login to post a reply

Server time is: 2024-11-24 16:27:29
Your offset time is: 2024-11-24 16:27:29