473,666 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Foosball Game Project

1 New Member
Could anyone help me with creating a flash foosball game for actionscript 2.0? Need to hand in a brief on Friday and mine is really not working. Please if someone could read through this code and correct me or can anyone provide me with any script for the game?


I have created 6 enemies with rectangles inside them that are the hitTests for the ball. The same with my characters. This is the code on my frame.



onLoad = function() {
enemyScore = 0;
yspeed = 0;
xspeed = 0;
friction = 5;
gravity = 5;
thrust = 5;
xspeed *= friction;
yspeed += gravity;
};

onEnterFrame = function () {





_root.ball._y += yspeed;
_root.ball._x += xspeed;
_root.ball._rot ation += xspeed;
//collision detection

enemyScoreText. text = enemyScore;


//Char01
if (_root.ball.hit Test(_root.men. char.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char.charLEFTto p)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char.charLEFTbo t)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char.charRIGHTt op)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char.charRIGHTb ot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Char02
if (_root.ball.hit Test(_root.men. char2.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char2.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char2.charLEFTt op)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char2.charLEFTb ot)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char2.charRIGHT top)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char2.charRIGHT bot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}

//Char03
if (_root.ball.hit Test(_root.men. char3.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char3.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char3.charLEFTt op)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char3.charLEFTb ot)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char3.charRIGHT top)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char3.charRIGHT bot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Char04
if (_root.ball.hit Test(_root.men. char4.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char4.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char4.charLEFTt op)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char4.charLEFTb ot)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char4.charRIGHT top)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char4.charRIGHT bot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}

//Char05
if (_root.ball.hit Test(_root.men. char5.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char5.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char5.charLEFTt op)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char5.charLEFTb ot)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char5.charRIGHT top)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char5.charRIGHT bot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}

//Char06
if (_root.ball.hit Test(_root.men. char6.charTOP)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.men. char6.charBOT)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.men. char6.charLEFTt op)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char6.charLEFTb ot)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.men. char6.charRIGHT top)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.men. char6.charRIGHT bot)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//enemies
//Enemies01
if (_root.ball.hit Test(_root.enem ies.enemies1.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies1.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies1.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies1.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies1.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies1.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Enemies02
if (_root.ball.hit Test(_root.enem ies.enemies2.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies2.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies2.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies2.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies2.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies2.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Enemies03
if (_root.ball.hit Test(_root.enem ies.enemies3.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies3.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies3.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies3.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies3.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies3.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Enemies04
if (_root.ball.hit Test(_root.enem ies.enemies4.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies4.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies4.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies4.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies4.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies4.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Enemies05
if (_root.ball.hit Test(_root.enem ies.enemies5.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies5.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies5.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies5.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies5.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies5.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}


//Enemies06
if (_root.ball.hit Test(_root.enem ies.enemies6.ch arBOT)) {
_root.ball._y -= yspeed*25;
}

if (_root.ball.hit Test(_root.enem ies.enemies6.ch arTOP)) {
_root.ball._y -= yspeed*-25;
}


if (_root.ball.hit Test(_root.enem ies.enemies6.ch arLEFTbot)) {
_root.ball._x -= 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies6.ch arLEFTtop)) {
_root.ball._x -= 100;
_root.ball._y += -yspeed*-25;

}

if (_root.ball.hit Test(_root.enem ies.enemies6.ch arRIGHTbot)) {
_root.ball._x += 100;
_root.ball._y -= yspeed*25;

}

if (_root.ball.hit Test(_root.enem ies.enemies6.ch arRIGHTtop)) {
_root.ball._x += 100;
_root.ball._y += -yspeed*-25;

}




//restrictions
if (_root.ball.hit Test(_root.grou ndBottom)) {
_root.ball._y -= yspeed*25;
_root.ball._x -= xspeed*25;
}


if ((_root.ball.hi tTest(_root.gro undLeft))&&(_ro ot.ball._x < 0)) {
_root.ball._x += 120;
}

if ((_root.ball.hi tTest(_root.gro undRight))&&(_r oot.ball._x > 0)) {
_root.ball._x += -120;
}


if (_root.ball.hit Test(_root.grou ndTop)) {
_root.ball._y += yspeed*25;
_root.ball._x += xspeed*25;
}

//goals
if (_root.ball.hit Test(_root.home Goal)) {
enemyScore++;

}



};


//This is the code on my characters.
onClipEvent (load) {
rotate = 0;

}

onClipEvent (enterFrame) {



if (Key.isDown(Key .RIGHT)) {
this._x += 15;
}
if (Key.isDown(Key .LEFT)) {
this._x -= 15;
}






}


//This is the code on my enemies.
onClipEvent (load) {
enemyspeed = 2;
enemystepsright = 0;
enemystepsleft = 0;
enemydir = "left";
}
onClipEvent (enterFrame) {

if (this.hitTest(_ root.groundLeft )) {
enemyspeed = 0;
enemystepsright = 0;
enemystepsleft = 0;
dead = true;
}

if (!dead) {
if (enemydir == "right") {
enemystepsright += 0.5;
this._x += enemyspeed;
} else if (enemydir == "left") {
enemystepsleft += 0.5;
this._x -= enemyspeed;
}
if (enemystepsrigh t == 50) {
enemystepsright = 0;
enemydir = "left";
} else if (enemystepsleft == 50) {
enemystepsleft = 0;
enemydir = "right";
}
}
}
Feb 24 '10 #1
0 1376

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1835
by: yongbl | last post by:
Hi, I need to do a client-server project that involves TCP/IP and XML. I want to make it a meaningful project. My friends suggested doing a project on Web Service. What kind of web services should I do? Any suggestions? Thanks in advance, Yong
1
1298
by: alcueca | last post by:
Hi, I've been programming with python and pygame for a year now, I started a RPG game, did some small toy apps (like exploring mandelbrot set) and an entire End-of-Career project about Evolutionary Computing and Natural Algorithms (5000 lines more or less) with this language. I'd like to use this knowledge in some funny way, I'd like to code a good game, maybe some RPG or platform-type, but I don't want to do it alone, neither to start...
7
8048
by: ashwin2mittal | last post by:
Dear friends, I am looking for help regarding major project ideas in C and C++. This project is a part of the my computer engg curriculum. Kindly help me in finding out the ideas ASAP. Thanks, Ashwin
1
1596
by: Vladimír Kolesnik | last post by:
Hi, there we need help concerning setting project under source control. We want to have a project on the server, and developers in the local network working on this project. We decided to use strategy officialy called "Isolated Development". We studied help in Visual Studio .NET called "Web Projects and Source Control Integration in Visual Studio ..NET". First we created solution on machine: A (server), then added a web project to this...
20
1646
by: venkatmail20034u | last post by:
hai to everybody, i desired to do a project in c? if u have idea about what types of problem solved by the c language? and also specify if u have any project title with description please specify to me thanks in advance
4
2205
by: robinsand | last post by:
My apologies to those of you who are more advanced Visual C++ .NET programmers, but I am working on a project for an MBA course that is condensed into an eight-week schedule, and I need help getting a program up and running with proper files and documentation to be handed in for a grade (on Microsoft Visual Studio .NET 2003). I am being graded on how well I incorporate advanced C++ features such as inheritance, polymorphic programming,...
0
986
by: rejwan | last post by:
Hello, i'm currently working on an online game (browser based), and obviously, since all of the contents is meta-data, I have loads of DB-related work. Recently I came into a brick wall while trying to figure out how to make one of the more important features of my game to work. This is the situation: Each player has a "game_id" and "score" columns; "score" is always recalculated, depending on the stats of the player (And indexed)....
0
1493
by: Rahtgaz | last post by:
Hello everyone, I'm wanting to start implementation of a pet project game IO mechanism. The game is console based. A cross between MUD and Rogue types. For I/O operations I'll be using ncurses (PDCurses to be accurate). Mainly taking advantage of colors in the console and wanting to minimize any work in porting it to Linux and Mac. What I'm thinking doing is designing two singletons CPrompt, CParse.
0
1674
by: Shawn Minisall | last post by:
For my final project, I'm trying to do a GUI based game similar to are you smarter then a 5th grader. I've been working on it and am stuck with some code someone helped me with to randomize the A,B,C,D letters that the correct answer is assigned too. The code that does this is highlighted in bold and the code that assigns it to a variable is also in bold so I can test it in the console window. Problem is, it's always stuck at letter A...
5
4103
by: Karlsen | last post by:
Hi everyone. I've been browsing your forums for a week or too, looking for information about RPG games. I'm very new to the whole C++ thing, but feel like im getting a hang of it. As a part of my examn project this year, i've decided to program a simple 2D-Rpg game (if possible!). Let me just tell your about my basic idea, then ill get to the questions. The game: I would like to make a very simple 2D inviroment, where the player will...
0
8445
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6198
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.