Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-04-2002, 11:40 AM   #1
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Default borders for a game

hi everybody

i got a problem in a game. my movie has the following dimensions:
550x400 px. i got a flying object (ship) in the movie. it shouldn't be possible to fly out of the stage. i created 4 clips around the stage and attatched the following script: this is for the left border:
onClipEvent (enterFrame) {
if (this.hitTest(_root.ship)) {
_root.ship._x = _root.ship._x+12;
}
}
it works like this, but not propperly !!! the "ship" gets "nervous" and it's quite difficult to get it out of the "hitTest"

is there another way to stop my object on every side of my movie ???

i hope you'll understand what i mean...

thanks in advance for you help!!!:-)
cuba is offline   Reply With Quote
Old 05-04-2002, 02:54 PM   #2
Ricod
(@_@) -("pretty lights")
 
Ricod's Avatar
 
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,988
Default

U could include a piece of code stating that the _x of your ship may never be less than 0 + half the width of your ship (assuming that the registration point is in the center) and never more than 550 - half the width of your ship. The same for the _y, but with 400. Just include an if statement in your control code.
__________________
RicoD
Link ?
Ricod is offline   Reply With Quote
Old 05-04-2002, 03:27 PM   #3
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Default game

thanks for your reply, could you post an example: do i have to attach the code to the ship ???

thanks a lot

cuba
cuba is offline   Reply With Quote
Old 05-04-2002, 03:35 PM   #4
Ricod
(@_@) -("pretty lights")
 
Ricod's Avatar
 
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,988
Default

exapmle :
Code:
on (keypress=<Right>){ //dunno the keypress thing at the moment, plz check
leftBorder = _root.myShip._width / 2;
rightBorder = 550 - leftMost;
if (_root.myShip._x >= leftMost && _root.myShip <= rightMost) {
// insert here the code that u use to move your ship right, depending on wether u want to take different things in account like speed, upgrades, gravity (?) etc. 
}
do the same for left, and for up and down replace 550 with 400 and call the variables upperBorder and lowerBorder or sumthing.
__________________
RicoD
Link ?
Ricod is offline   Reply With Quote
Old 05-04-2002, 04:59 PM   #5
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Default

thanks, i'll try that...
cuba is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Card Match Game, Colour Me In Pictures and Board Game Total Frigging ActionScript 2.0 4 02-21-2005 01:04 AM
word search game with AS2 black General Chat 5 08-12-2004 10:44 AM
[AS2] Tile game or not tile game? krolben Gaming and Game Development 4 07-28-2004 01:41 PM
Game - freelancer required fatherb Projects and Positions 6 07-18-2003 12:47 PM


All times are GMT. The time now is 04:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.