hi
im creating a brick builder game
ive got the paddle and ball moving now i just want the ball to bounce off the paddle hit the brick and then the brick disappears, i am using document classes, im just stuck on this bit, any help would be appreciated, please need your help lol - package {
-
import flash.display.*;
-
import flash.events.*;
-
import flash.text.*;
-
import flash.ui.Mouse;
-
public class Breakout extends Sprite {
-
var ball_mc:Ball;
-
var xVel:int=10;
-
var yVel:int=10;
-
-
var paddle_mc:Paddle;
-
-
function Breakout() {
-
ball_mc=new Ball();
-
ball_mc.x=100;
-
ball_mc.y=100;
-
this.addChild(ball_mc);
-
-
paddle_mc=new Paddle();
-
paddle_mc.x=250;
-
paddle_mc.y=380;//this positions the paddle on the screen, currently at the bottom of the screen//
-
this.addChild(paddle_mc);
-
paddle_mc.init();
-
start_btn.addEventListener(MouseEvent.CLICK,startGame);
-
this.addEventListener(Event.ENTER_FRAME, updateGame);
-
}
-
function startGame(evt:MouseEvent) {
-
this.addEventListener(Event.ENTER_FRAME,moveBall);
-
start_btn.visible=false;
-
}
-
private function updateGame(e:Event) {
-
paddle_mc.moveIt();
-
}
-
function moveBall(e:Event) {
-
ball_mc.y=ball_mc.y-yVel;
-
ball_mc.x=ball_mc.x-xVel;
-
if (ball_mc.x>this.stage.stageWidth || ball_mc.x<0) {
-
xVel=xVel*-1;
-
}
-
if (ball_mc.y>this.stage.stageHeight || ball_mc.y<0) {
-
yVel=yVel*-1;
-
}
-
}
-
//Hitting the paddle
-
if (Ball.hitTestObject(Paddle)) {
-
calcBallAngle();
-
}
-
}
-
}
- package {
-
import flash.display.MovieClip;
-
import flash.events.*;
-
import flash.events.KeyboardEvent;
-
-
public class Paddle extends MovieClip {
-
var left:Boolean;
-
var right:Boolean;
-
-
function Paddle() {
-
this.stop();
-
}
-
function init() {
-
this.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
-
this.stage.addEventListener(KeyboardEvent.KEY_UP,keyUpHandler);
-
}
-
-
private function keyDownHandler(e:KeyboardEvent):void {
-
if (e.keyCode==37) {
-
left=true;
-
}
-
if (e.keyCode==39) {
-
right=true;
-
}
-
}
-
private function keyUpHandler(e:KeyboardEvent):void {
-
if (e.keyCode==37) {
-
left=false;
-
}
-
if (e.keyCode==39) {
-
right=false;
-
}
-
}
-
-
function moveIt() {
-
if (left==true) {
-
this.x-=10;
-
}
-
if (right==true) {
-
this.x+=10;
-
}
-
if (this.x <= 48) {
-
this.x+=10;
-
}
-
if (this.x >= 500) {
-
this.x-=10;
-
}
-
}
-
}
-
}
my two class files, your help would be much appreciated thank you
0 1250 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Manu |
last post by:
How can i do with a flash object for obtain the w3c label ?
the "embed" is not accepted !
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
|
by: Uma Vivek |
last post by:
Hi,
I have a problem with Flash remoting via .NET . I seem to have all the
code right, but flash does not seem to display the data at all.
Here's is what Ive done so far...
(1) Ive installed Flash Remoting MX, and copied over the contents of
wwwroot\flashremoting\bin into my web application's folder\bin.
|
by: John Bailo |
last post by:
The war of the OSes was won a long time ago.
Unix has always been, and will continue to be, the Server OS in the form
of Linux.
Microsoft struggled mightily to win that battle -- creating a poor man's
DBMS, a broken email server and various other /application/ servers to
try and crack the Internet and IS markets.
In the case where they...
|
by: Keith Rowe |
last post by:
Hello,
I am trying to reference a Shockwave Flash Object on a vb code behind page
in an ASP.NET project and I receive the following error:
Guid should contain 32 digits with 4 dashes
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
On the aspx page I have the object tag as follows:
|
by: Scott |
last post by:
I have written an Access application that our employees use on a daily basis
to enter information.
It's comprises of a series of forms, a few data integrity check queries that
run in the background and a few reports.
Quite often I lament at the limitations of using forms, in particular how to
make something that looks "stylish".
This...
| |
by: tanv70 |
last post by:
Hello,
I am considering starting up my own online gaming site to include muti-player bingo, slots, keno, and possibly more.
This will need to include player registration and password retrieval, scripts for the games to run smoothly, database for wins/losses, a My account area so players can edit information, e-commerce so I can actually...
|
by: Jeff Rush |
last post by:
At PyCon this year we're going to have a multi-day game programming clinic and
challenge. This is a first-time event and an experiment to find those in the
Python community who enjoy playing and creating games. Python has several
powerful modules for the creation of games among which are PyGame and PyOpenGL.
On Friday evening, Phil Hassey...
|
by: Neo Geshel |
last post by:
Greetings.
BACKGROUND:
My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are
delivered as application/xhtml+xml for all non-MS web clients, and as
text/xml for all MS web clients (Internet Explorer).
My flash content was originally brought in via the “flash satay” method,
but I have since used some server-side magic...
|
by: dosingh |
last post by:
i've put this page together using asp, html, javascript amd flash.
java passes a number of variables over to the flash file but the flash graph does not appear. The error which appears is SWFObject in undefined. The script tag contained <script type="text/javascript"> but after taking the "text/" out the, the pages shows not error but also not...
|
by: breckj |
last post by:
Hi,
I would like to learn C++ and become a gaming programmer. Your suggestions to the following are appreciated.
Q1) What development software do you suggest (compiler, code editor, ide, etc)? Free versions as well as priced, thanks.
Q2) Regarding OS, does anyone recommend Linux over Windows (XP, Vista, 7)? What OS do you recommend?
Q3)...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |