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 / Sprite Problem

Author
Message
caleb870
19
Years of Service
User Offline
Joined: 13th Jul 2005
Location: LOOK! Over there!
Posted: 1st Aug 2005 00:17
When I run this script I made my sprite doesn't move:

It's supposed to move to random spots on the x axis on a sprite otherwise if sprite 1 and 2 aren't colliding then it replaces it back onto the sprite. AAlso does anyone have a suggestion o how to make the object move with a random cosmine effect(some smooth movement)?
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Aug 2005 03:53 Edited at: 1st Aug 2005 03:54
It looks like you've programmed sprite 2 to only move if it collides with sprite 1. If it doesn't then it will just stay still at 20,500. And if it's just staying still, then I guess it's not likely to ever collide with anything.

To make something move according to a cosine function (is that what you meant?), you would do something like this:



where a is the amplitude of oscillation and c is the centre of the oscillation, and speed# is the speed of the oscillation.

caleb870
19
Years of Service
User Offline
Joined: 13th Jul 2005
Location: LOOK! Over there!
Posted: 1st Aug 2005 07:57
I ran the code although it still stayed in place I'm not sure why. My full source code is:

The 1st sprite is mainly the background, the 2nd is the sprite that is supposed to move in a random cosine effect mainly on the x axis(left to right) where if it would move off-screen it would be placed back on sprite 1. The 1st sprite is a 640x480 size. If I wasn't that clear earlier, though I greatly appreciate of your assistance. My program is DBPro.

Hmmm... I can't think of a signature (How original)
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 1st Aug 2005 12:27 Edited at: 1st Aug 2005 12:29
Letters like a, c, y, and the word speed# are called variables, which store different numbers. But if you don't tell them what numbers to be, they will be zero - so start by saying what they are equal to.

Try:



That should produce a cosine movement - although I'm not really sure if that's what you're after!

caleb870
19
Years of Service
User Offline
Joined: 13th Jul 2005
Location: LOOK! Over there!
Posted: 2nd Aug 2005 23:53
Works perfectly, thank you!

Hmmm... I can't think of a signature (How original)

Login to post a reply

Server time is: 2024-09-24 01:32:52
Your offset time is: 2024-09-24 01:32:52