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 / Quick 2D Help!

Author
Message
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 8th Aug 2010 07:51
This is my code

the sprite won't move left or right

DBpro 7.4-7.5
Sparky's collision DLL
Windows vista

I want coke, not Pepsi!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Aug 2010 08:36
Hi, I think you need to draw the sprite inside the loop, so move 'sprite 2,1,1,1' into your do-loop.

A clever person solves a problem, a wise person avoids it - Albert Einstein
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 8th Aug 2010 09:46

I tried that but he moves up and down not left and right

I want coke, not Pepsi!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Aug 2010 10:51
Ok, try this


A clever person solves a problem, a wise person avoids it - Albert Einstein
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 8th Aug 2010 11:19
Quote: "I tried that but he moves up and down not left and right"

to solve problems you have to problem solve. X is horizontal, Y is vertical.


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 8th Aug 2010 17:58 Edited at: 8th Aug 2010 18:07
Quote: "to solve problems you have to problem solve. X is horizontal, Y is vertical."

I was thinking that but I thought you'd have to define those as variables.

EDIT: I tried this

and it didn't work, I also tried y-1 and y+1 and nothing. I know that Y is up/down but it was worth a shot

I want coke, not Pepsi!
AJAtom
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 8th Aug 2010 19:14
just take your original code and put in the command

sprite 1,x,y,1

at the end
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 8th Aug 2010 19:21 Edited at: 9th Aug 2010 00:29
ok, thanks will try. I got it, also is this the best way of movement or is there an easier or faster or better way? Also my screen is green now that I made a camera and not white, and the text 1,1,screen fps is coming up with an error.


Also if I saved a sprite in .png would it already have alpha? Like would there be no white background or would I have to go into a program and remove the white and save as .png?

EDIT: since I can't bump yet this will be my bump for now

I want coke, not Pepsi!
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 9th Aug 2010 04:51 Edited at: 9th Aug 2010 05:05
solved screen fps, and made it so it shows x and y co'ords. Now just need to know if my movement is the best/easiest/fastest way to doing things and the .png/alpha.
Code so far:

Also my camera doesn't follow my 2d sprite.

I want coke, not Pepsi!
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 9th Aug 2010 22:07
Your camera won't move because you need to implement a scrolling/Tile system. The way you are moving is good for now, but you will have to tweak it when your game gets larger. I suggest using functions as soon as possible because it makes debugging and changing small areas of code a LOT easier. Such as:



Incase you don't know:
1) calling the global command makes that variable usable in the entire program
2) calling the gosub command brings the program to a different place, breaking the top to bottom reading. It then returns to the place where it was called with the return command
3) calling the function command makes a command that you call whenever you want. It's useful for grouping similar code and if you have something you need to call more then once.

I hope this helps

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 9th Aug 2010 22:24
I don't really want to use gosubs or gotos and I was thinking this, but it doesn't really work, why?


I tried to make a plane, position it where the sprite is, then position the camera where the plane is but the camera doesn't move.

I want coke, not Pepsi!
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 10th Aug 2010 06:27

I tried that, but the plane won't move.
Also how do I make the plane invisible? Ghost object on helps but.. not quite invisible

I want coke, not Pepsi!
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Aug 2010 16:15 Edited at: 10th Aug 2010 16:17
set alpha mapping on objNo, Alpha %

Where the alpha percentage goes from 0% (completely invisible) to 100% (completely visible)

hide object objNo

Simply hides the specified object


Hope that helps

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 10th Aug 2010 20:52
@ProF thanks that helps, but do you know why my plane isn't moving with my sprite?

I want coke, not Pepsi!
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 10th Aug 2010 22:13 Edited at: 10th Aug 2010 22:14
Try positioning the sprite using the object screen x() and object screen y() commands.

I think what you do is move the plane and the camera so that the plane is in the middle of the screen; and then position the sprite using the same co'ords, but on the 2d screen.

The difference between 2d and 3d being on a 640 x 480 screen, then 320,240 will always be in the centre of the screen regardless of how far away or what direction the camera is set to. (Sorry, thats prolly a really lousy explanation)

>Edit<
Actually, thinking about it, if you want the sprite to stay in the middle of the screen, then just use screen width()/2 and screen width()/2?

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 10th Aug 2010 22:38
ProF can you show an example using my code? I don't really get it

I want coke, not Pepsi!
CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 11th Aug 2010 04:27
Bump

I want coke, not Pepsi!
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 11th Aug 2010 12:25


This show what I was talking about.

The plane moves about the scenery boxes when the arrows are pressed.

The sprite moves about the screen when the arrows are pressed.

See how the 2 sets of co'ords don't match up?

CocaCola
14
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 11th Aug 2010 21:43
@ProF test out that code with one of your sprites, the plane moves slower than the sprite, so the sprite can move out of the screen.

I want coke, not Pepsi!
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 12th Aug 2010 03:28 Edited at: 12th Aug 2010 03:33
Yes, I know... Thats what I was trying to explain; the difference between 2d (screen) co'ords and 3d (what you see through the camera) co'ords.

As I said earlier, try using object screen x() and object screen y() to position the sprite, or as the plane will ALWAYS be in the middle of the screen, simply use screen width()/2 and screen width()/2.

>edit<

To clear up any ambiguity simply replace this line



with either



or



Login to post a reply

Server time is: 2024-11-23 11:09:44
Your offset time is: 2024-11-23 11:09:44