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.

2D All the way! / Border

Author
Message
zDough BoyZ
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 31st May 2007 01:55
I am making a game that is very very basic over head 2d shooter. but i just cant find code to put a border around the screen the the charecter cant leave the screen. Please help!

The Internet Is TUBES
Agent Dink
21
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 31st May 2007 04:44
You only need to post once.



That should work, it's untested, but I see no reason why it won't...

Free music, textures, models, and tutorials.
Silver Dawn
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st May 2007 05:17
I would change Agent Dink's code slightly, allowing for the width and height of playersprite, like this:


I have not tested this code either, but it looks like it would work.

LB
zDough BoyZ
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 31st May 2007 07:05
am i supposed to replace any pieces of your code with mine. it say it doesn't under stand the first line.
Sorry I'm Way new at this.

heres my code so far with yours added.



The Internet Is TUBES
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 31st May 2007 13:46
For readability, you should indent your code. It makes it harder to edit and fellow coders may not want to invest their time helping you if the code is not indented.

I don't see anything wrong with the command on the first line assuming that you are using DBP. While it has nothing to do with the error given, you should turn the backdrop on before you color it.

In your do - loop, you have listed
Quote: "If sprite x(playersprite)<0"
twice. It may be that this is giving you the error.

Regarding your original border post: The code you have listed will allow the sprite to move off the right and bottom edges of the screen. I gave you a suggestion on how to fix that already.

LB
zDough BoyZ
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 31st May 2007 21:29
i think i just need a little more instruction on where to put the code you gave into mine. I have been trying to work it out but i can seen to find the right spot or add anything.

This is my original.



Im not sure if i would make a new do/loop or just add it into my only one.

Thanks for all the help.

The Internet Is TUBES
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Jun 2007 06:22
@zDough BoyZ

I have edited your code. You actually had a few problems in it.


You had not set the playersprite variable to one. Also, there is no 'position sprite' command in DBP, you just put 'sprite #,X,Y,IMAGE'

Agent Dink was correct in his code (my apologies Agent Dink), because I missed it that you had offset the sprite to the center. Still, half of the sprite goes off the screen. If you are looking for something other than that, then your code would have to be altered.

The code could be done more efficiently, but I didn't want to edit it beyond what I had so that you could see what I did.


LB
zDough BoyZ
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 1st Jun 2007 07:02
Thanks you so much for this it works perfect. Sorry it took so long for something so simple.

The Internet Is TUBES

Login to post a reply

Server time is: 2025-05-16 20:27:22
Your offset time is: 2025-05-16 20:27:22