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 / moving my sprite wont reponse to key press

Author
Message
TheCodeHasEyes
14
Years of Service
User Offline
Joined: 21st Oct 2010
Location:
Posted: 23rd Oct 2010 18:36


it wont move!! where did i go wrong?

i have my start postion where i what it to be 300, 400, but controls wont work.
Lewis999
14
Years of Service
User Offline
Joined: 23rd Oct 2010
Location:
Posted: 23rd Oct 2010 23:12 Edited at: 23rd Oct 2010 23:21
put "sprite 1,300,400,1" before the loop then add "cls" and "PASTE SPRITE 1,xpos,ypos"

not sure if this works but it should do.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Oct 2010 23:12 Edited at: 23rd Oct 2010 23:14
@TheCodeHasEyes,
Ok, missed this when replying to your other thread - please reuse the existing threads in future when you are not changing the subject.

Clue: You are amending the xpos and ypos variables ... but where are you applying them to the sprite?

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
TheCodeHasEyes
14
Years of Service
User Offline
Joined: 21st Oct 2010
Location:
Posted: 23rd Oct 2010 23:37
ok thanks Ian, will remember in future, sorry.

now, on to the code.

if i write code like this it moves but my starting point is totaly way off.



so if i set a starting point for the sprite using a command i have yet to discover it should work.

i'll give it a go, if theres a easy way please just say i am trying to learn.

many thanks.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Oct 2010 05:57
I'll give you another clue.

Put this right after LOAD IMAGE:


TheCodeHasEyes
14
Years of Service
User Offline
Joined: 21st Oct 2010
Location:
Posted: 24th Oct 2010 10:40
thanks for all your help, im getting there.



up and down working fine, sprite position fine.

left and right im still trying to figure out as when pressed the sprite moves up?

ive tried rotate sprite but thats not what i need.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2010 16:34
I don't use MOVE SPRITE myself to move sprites - I generally reposition them.

However, sticking to your method, you can rotate the sprite 90 degrees, move it, then rotate it back to it's original orientation.


Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
TheCodeHasEyes
14
Years of Service
User Offline
Joined: 21st Oct 2010
Location:
Posted: 24th Oct 2010 22:54
thanks to everyone who posted on this topic im sure its helped others too.

now i have a even bigger problem, im working on a pratice pong game

everything is great so far but moving the ball randomly is becoming to be a headache ive tried alot of code to get the ball moving randomly on its own



thats what i got so far, i have a idea of how to create collision hit with ball and player, but for now its getting that ball moving.



obviouly the second code snippet doesnt work, i though it would have. ive tried and tested lots of combination of code to no avial. can i pick someones brains on this matter? would be grateful!

thanks
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Oct 2010 18:17
Quote: "now i have a even bigger problem, im working on a pratice pong game"


Lets go back a bit first. Both IanM and myself don't usually use MOVE SPRITE we reposition them. Generally when you use MOVE SPRITE where the sprite moves is based on the sprites current rotation. That's why IanMs last code snip has a ROTATE SPRITE command. It's a lot easier to just reposition the sprite... especially if you don't really need/want your sprites rotated.

Here's an example of repositioning the sprite:


In the place of MOUSEX() and MOUSEY() put your own variables that represent the x and y coordinates of the sprite (remember my clue). Use the same method for moving the ball but just remember not to use the same variables for your paddle and ball if you want them to go different ways.

Also you really should use .png instead of .jpg. .jpgs change the colors they use so a solid color is no longer a solid color. .pngs also allow transparencies so you can make things like windows to reveal images/spites that are behind the window (makes games cooler).

Login to post a reply

Server time is: 2024-11-24 09:58:47
Your offset time is: 2024-11-24 09:58:47