Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Easy - Pong AI Ques.



Ok just to see if I could do it(never really got into game programming) I tried to make a pong game everything works so far but I have a problem with this:
Flash code:

PHP Code:


onClipEvent(enterFrame) {
if(_global.cspeed == 0) {
}else{
    if (this._y != _root.ball._y){
        if(_root.ball._y < this._y){
                this._y -= _global.cspeed;
        }else if(_root.ball._y > this._y){
                this._y += _global.cspeed;
        }else{
                this._y = this._y;
        }
    }
}
}



The problem is that instead of moving smoothly up the screen it looks like it s shaking up and down really quickly, but I would like it to be smooth.
Please help.



FlashKit > Flash Help > Flash MX
Posted on: 06-05-2004, 10:43 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Easy AS Ques.
ok so I have a flash doc..theres a an MC called target on mainstage that has the entite site in it (doing a fullscreen centered website)..now I have MC nav buttons on the stage (inside target). Inside one of the nav buttons I have a line of AS that says


ActionScript Code:
this.onRelease = function(){
    _root.target.loadMovie("bioresume.swf", "loader");
}


Now im not sure If im doing that right..but what i want to happen is; after u release the button, load the ext swf into the empty MC called "loader". But what seems to be happening is it loads the ext swf but everything else on the site disappears. See I originally had this as my AS cause i thought this made sense but it ends up not doing anything:


ActionScript Code:
this.onRelease = function(){
    loadMovie("bioresume.swf", "loader");
}


So if anyone knows what I did wrong, much appreciation. Heres the site link if u want a visual:

www.josephsernio.com/test

Easy As Ques.
Ok for some reason the end of this code doesnt work.. on release, i want it to take me to frame 2..and it wont...btw this a movie clip that has button properties through AS:



stop();

this.onEnterFrame = function(){

if(rewind == true){

prevFrame();

}

}

this.onRollOver = function(){

rewind = false;
play();

}

this.onRollOut = function(){

rewind = true;

}

this.onRelease = function(){
gotoAndStop(2);

}

Nav Ques
Hey guys I seem to remember a thread regarding how to make this kinda of NAV :

http://dopepope.com/ntps/Build_onff/


Anyone remember the thread or have a link on a tutorial to dup that kind of load jpg and have the window resize automatically...thanks all

_parent. Ques
im trying to load an external jpg. and the file name of this jpg is the name of the mc 2 levels above the command.
if u dont understand this is thi code im trying to use

Code:
x = _parent._parent._name;
loadMovieNum("x".jpg, 1);

i also tried putting th eparent crap in the load move itself like this

Code:
loadMovieNum("_parent._parent._name".jpg, 1);

and its still not working. any one able to give some advice

AttachMovie Ques
Hi -
I'm using the code below to bring mcs from the Library to the stage. It works fine until I tried to add the x,y at the end.
I thought there was a way to include _x and _y coordinates to the same statement as the attactMovie. Is there?

TIA the correct way to accomplish this.

jl







Attach Code

mc_btn2.btn2.onRelease = function():Void {

attachMovie("Q2WithGame","Q2Game",this.getNextHighestDepth,[_x=45,_y=110]);

};

Simple AS 1.0 Ques
AS 1.0
I have this code in a keyframe on the main timeline:

var score = 0;
if (score == 2500){trace("winner")}

Othe stage in the maintimeline i have a dynamic text field I labeled "score" in the var box. The instance name is "pts" but i wasnt sure if i needed an instance name anyway here. The score box works fine as far as keeping score but when it reaches 2500, I dont get my trace. What am I missing? Thanks

-Chris

Stupid Ques
hello new be ere (welsh) i got a prob wanderin if some1 could help im tryin to get a news page that updates ive got this off yahoo

this

so now tryin to use it but flash does ntlike it im prob doin some thing stupidly wrong now on the verge of not botherin

PLEASE HELP

Attaching MC Ques
hi.. anyone out there can give me a tutorial which teaches attaching a MC to another MC?? urgent..

Stupid Ques
hello new be ere (welsh) i got a prob wanderin if some1 could help im tryin to get a news page that updates ive got this off yahoo

this

so now tryin to use it but flash does ntlike it im prob doin some thing stupidly wrong now on the verge of not botherin

PLEASE HELP

Flash Ques
please can you explane me how can I make this file like on this site:
http://www.t-s-k-b.com .You go on this site and press SAKUBA WORKS and then button Painting/Drawing

I would like to make a picture gallery like in Painting/Drawing: So how I can make when the mause on the button to show small image of the picture and when I press the image to open the picture how is on the site(not in a new window)?
Please tell give me advice how could I make it!
thank you

Another Loading Ques
Is it possible to make the movie load let's say... only the 1st 2 frames of movie that has 8?

Button Ques
Ok real dumb ques..I have this animation..u can dl it from here: www.zeroxposur.com/test/nav.fla
So what I want to do is have 5 buttons fade in ..onto the bar as it finishes its animation..but I dont know how to do it.. Can anyone point me in the right direction. Thanks

MC Loader As Ques.
im working with the moviecliploader AS..so a button loads an ext SWF and also has a percentage loader .. so on my mainstage i have a loader mc (instance name "loader")and a holder mc (instance name "holder")..heres my AS on the main timeline:

var mcl:MovieClipLoader = new MovieClipLoader();

var mclL:Object = new Object();

mclL.onLoadProgress = function(target,loaded,total) {
loader.percent.text = Math.round((loaded/total) * 100) + "%";
}

mclL.onLoadInit = function() {
loader._visible = false;
loader.percent.text = "";
}

mcl.addListener(mclL);





Now i have another MC that houses about 20 or so buttons..so within the buttons MC i have say this for one of the buttons:

b4sub.onRelease = function() {
_root.loader._visible = true;
_root.mcl.loadClip("LevisCampaign.swf",holder);



And unfortunetly it doesnt to load the ext. swf..did I code the _root incorrectly?

Thanks for your help.

Fscommand Ques
Hi all, I was working with fscommand, when it struck me what FSCOMMAND stands for.

"Future Splash Command"

Can anybody confirm this, or am I mad, lol

Later

ORANGE900

LoadVariables Button Ques
Hello all. I have this code attached to a button calling up a different text file to a dynamic text field and it works fine, except I'm having to hit the button "twice" for it to work. Can't figure out why. Can someone enlighten me please?


code:

on (release) {
scrolltext = scrolltext1;
loadVariables ("scrolltext1.txt", scrolltext1);
}

Thanks in advance

Movie Clip Ques
Hey i just started doing flash yesterday and i am doing a text fade

I made the motion tween and and everything and when i go to control and play everything is smooth but when i go to test movie nothing it just stays the same and doesnt fade :> plz help me

Movie Clip Ques
Hey i just started doing flash yesterday and i am doing a text fade

I made the motion tween and and everything and when i go to control and play everything is smooth but when i go to test movie nothing it just stays the same and doesnt fade :> plz help me

Quick Mask Ques
Im sure this is an easy one.. on the foofighters website http://www.foofighters.com When U click a button that flourish/swashy graphic looks like it is unwinding or growing rather. I would like to get the same effect.. Its obviously a mask of some sort. I know who to mask, im just figuring its a mask that is animated somehow. Anyone have an idea? Appreciate any insight into this. Peace

-R

Quick Actionscript Ques.
Ok so im building a portfolio website and basically if you click on the art image it goes tothe next art image..I have it set up so the art images are buttons and when u click it, it is coded to goto next scene..On one scene however the art image is a movieclip (fading effect)...now how do you write the actionscript so if you click on the movieclip it goes to the next scene? I dk im right but...my guess is to put the MC within a button symbol? But I dk. Thanks guys.

UI Text Input Ques.
Ok so Im making a form in flashmx2004..I drag out onto the stage the UI compnent textinput box..now I want to make this box multiline but it doesnt give me the option to do so. Do I have to make input boxes in a different way?

Motion Guide Ques
Hi all,
Is it possible to create a motion guide, so the object connected to the motion guide is always in the centre of the screen.

What I mean is, if we were trying to go from point A to point B
we could see the full journey of the object travelling along motion guide in the centre of the screen.

A-------->--------->-------->------B

The sort of thing I mean is included, but with no motion guide instead, the car remains in the centre of screen and is able to move around the track which in turns moves the the track below.

Thanks for your time, sorry for the broken language. Hope you can help.

--------------
FLA = MM2004

<> QUICK QUES RE:Positioning After Dupe
Hi Im using a while loop and the dupliacteMovieClip() to dupe a certain number of my Mc's. I want to postion each duped Mc after its created with setProperty but I cant figure out how to do this within the same loop.
It complains in output box:

Symbol=playlist_Mc, Layer=Layer 2, Frame=1: Line 9: Expected a field name after '.' operator.setProperty(_root.playlist."box" + count, _y, vertpos);

Obviously I cant do the <"box" + count> bit, but how else can i do it?
(see code below)



Code:
onClipEvent(load){

var vertpos = 46;
var count = 0;
//create
while(count!=4)
{
duplicateMovieClip(_root.playlist.box, "box" + count, 1);
-->this doesnt work//setProperty(_root.playlist."box" + count, _y, vertpos);

trace(count);
count++;
}
//position
}


-Rich

Pleez Help With Random Keyframe Ques.
I have four different movie clips on four different keyframes (2-5) the first key frame has a clip with an invisible button over it. WHat I would like to achieve is onMouseover of the button in the first frame......I would like the playhead to randomly gotoAndStop on of the other frames (2-5). To give the illusion of random movement. The on mouseout return to the first keyframe. any help greatly appreciated....either a .fla I can study or some AS would be great.

Probably Simple LoadMovie Ques. For JPEGs
I have a target MC that I want to load some JPG's into in my Flash Movie. The Target MC's dimensions are 650x500px. The JPG's are the same. When I attempt to load them, I can notice that something has changed in the tone of the movie clip (I had the target MC a grey color then that color disappears) but the JPG does not load.

I tried a smaller JPG, like 1/4 the size, and it loaded OK. ANyone have a suggestion?

Action Script Ref Code Ques
Hello i keep getting this this action script error when i attempt to render this swf could some one explain what this error message means ......i am not sure what the variables are looking for ....... the version is Flash 8 - the action script is below and the error message is below that.......

#include "lmc_tween.as"
//classes are loaded on this frame
var state:com.collection.State = new com.collection.State(this);
// start program
var main:com.collection.Main = new com.collection.Main(this)
//
bg_img.tween("_alpha",100,1,"linear",.5)
stop()

Error message (below)

**Error** Scene=Scene 1, layer=actions, frame=5:Line 1: Error opening include file lmc_tween.as: File not found.
#include "lmc_tween.as"

**Error** Scene=Scene 1, layer=actions, frame=5:Line 3: The class or interface 'com.collection.State' could not be loaded.
var state:com.collection.State = new com.collection.State(this);

**Error** Scene=Scene 1, layer=actions, frame=5:Line 5: The class or interface 'com.collection.Main' could not be loaded.
var main:com.collection.Main = new com.collection.Main(this)

Total ActionScript Errors: 3 Reported Errors: 3

Action Script Ref Code Ques 2.0
Hello please see this link it is a follow up to the thread i created before....i am stil trying to figure this error out when i generate the flash swf it works but not properly... below is a link to what the swf looks like there are buttons that should show and i get this message (shown below) in the flash error box that says (output) when i hit ctrl+enter to generate the swf.... any suggestions...?

b1,b2,lgText,redText,arrow,a:link,a:hover
yo

http://www.amjaydesign.com/mainCol.html


http://board.flashkit.com/board/showthread.php?t=744878

Simple Ques About Blue Border Box
I'm using flash 8. When you draw something or import a picture flash 8 puts the blue border box around it. Well mine is gone. If I draw something and click on it it is a broken shape. How do I get the blue border box back?thanks

Loading Clips Into Levels? -quick Ques
Hi, I need a quick bit of code or at least somebody to give me an idea on how to actually have a clip load itelf into a specific level depending on the value of a variable. I want to do this as my duplicateMovieClip() code is putting MC's on higher levels than other elements (other Mc's) in my movie, and one of these elements in perticular needs to be the 'highest'.

I tried using setProperty() as below but it doesnt work, flash complains (I gather it doesnt consider '_level' as a property?)

Code:

setProperty(need2BHighest_Mc, _level, highestLevel);




Any help appreciated

Html Code Inside Flash Ques
I have a client who wants me too put some html inside the flash actionscript. He's not sure it will work and I'm not sure if it's possible or how to do it. Here's the code any suggestions thanks

<form action="/gift/save/1234" enctype="multipart/form-data"
method="post">
<input name="file" type="file" />
</form>

Pong In CBT
I am creating a CBT which consists of 5-10 frames. Each frame contains a separate movie which is stored in the library.

I need to have one of those movies be a pong type game. I can create the movable "bat" and the walls but can't figure out how to get the ball to bounce around randomly and keep score. Please help.

I'm using Flash MX.

Pong
Oki, so I'm writing a pong game for flash. I will freely admit that I'd probably trying to re-invent the wheel here, but it's for my own edification, so bear with me. I have everything working except for 1 detail, the ball is set to move a little faster, everytime it is succesfully hit by a paddle (using hitTest), this works fine except when the ball reaches such a speed (ball._x += 5 etc)that it basically jumps the paddle. The x position in frame A + speed means the x position in frame B is beyond the paddle, so no hitTest, even if the paddle is in the right position. The only solution I've come up with so far, is to make the increments as small as possible (ie: + 0.1) and increase the frame rate to something ridiculous like 300fps. Anyone have a better suggestion, as even this will eventually not work.

Pong Help
Hey,
I would like oy know if anyone knows how to make a little pong game. With the vaiables and codes. Thanks for your time!

Pong
right, ive just been asked by a friend to create some games for a site, simple enough, ive got some which i can give him, however, his first request is for a simple "pong" game...

I know pretty much everything i think, except the physics needed in order to make the ball bounce of walls and stuff, i know what you would need, the angle of incidence upon collision with the object is equal to the angle of incidence upon leaving it, but i would not know where to start this useing flash...

Help appreciated/needed :P

API-Only Pong :)
Hey all!
I haven't been here for a while, and i thought i might post this.
It's a PONG game, made entirely in AS.
Just make a new movie with 600*300 dimensions and preferably a black background (just not white!!!)...
code:
//Drawing API Pong By TrashLock
//(c) 2004, all rights reserved
Mouse.hide();
w = Stage.width;
h = Stage.height;
ball_speed = -1.2;
ball_y = 0;
fps = 120;
interval = Math.round(1000/fps);
max_speed = 4;
enemy_score_one = 0;
player_score_one = 0;
new_score_p = 0;
new_score_e = 0;
//initiate the playing area (it's just a ****ing line, and it requires 7 lines of coding, for ****'s sake!)
function createArea() {
_root.createEmptyMovieClip("area", 0);
with (_root.area) {
moveTo(w/2, 0);
lineStyle(5, 0xFFFFFF, 80);
lineTo(w/2, h+10);
}
}
//Create those little textboxes
function textBoxes(new_score_p, new_score_e) {
_root.createTextField("player_score", 1, 20, 10, 20, 40);
_root.createTextField("enemy_score", 2, w-40, 10, 20, 40);
score_style = new TextFormat();
score_style.font = "Verdana";
score_style.size = 20;
score_style.bold = true;
score_style.color = 0xFFFFFF;
score_style.align = "center";
player_score.selectable = false;
player_score.text = new_score_p;
player_score.setTextFormat(score_style);
enemy_score.text = new_score_e;
enemy_score.selectable = false;
enemy_score.setTextFormat(score_style);
}
//This is the function to create a player
function createPlayer(instancename, depth) {
_root.createEmptyMovieClip(instancename, depth);
with (_root[instancename]) {
moveTo(0, 0);
beginFill(0xFFFFFF, 100);
lineStyle(0, 0xFFFFFF, 0);
lineTo(10, 0);
lineTo(10, 50);
lineTo(0, 50);
lineTo(0, 0);
}
}
//this one's a bit hard, because it creates a ball
//rather than a square
function createBall() {
_root.createEmptyMovieClip("ball", 5);
with (_root.ball) {
moveTo(0, 0);
lineStyle(0, 0xFFFFFF, 0);
beginFill(0xFFFFFF, 100);
curveTo(0, -5, 5, -5);
curveTo(10, -5, 10, 0);
curveTo(10, 5, 5, 5);
curveTo(0, 5, 0, 0);
}
}
//initiate ball position
function int_stuff() {
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
_root.enemy._x = w-20;
_root.enemy._y = h/2-30;
}
//show a "click to play" text...
function click_2_play(message) {
_root.createTextField("click2play", 10, 0, 20, w, 200);
with (_root.click2play) {
text = message;
selectable = false;
setTextFormat(score_style);
}
}
//create a BIG button over the entire stage... don't ask
function createBigButton() {
_root.createEmptyMovieClip("big_button", 20);
with (_root.big_button) {
beginFill(0x000000, 0);
moveTo(0, 0);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
}
}
//all the load functions
_root.onLoad=createArea(), createBall(), textBoxes(player_score_one, enemy_score_one), createPlayer("player", 3), createPlayer("enemy", 4), int_stuff(), click_2_play("Click Anywhere To Play"), createBigButton();
_root.big_button.onPress = function() {
playing = true;
click_2_play("");
};
//control player
function controlPlayer() {
if (playing) {
_root.player._x = 20;
_root.player._y = _root._ymouse-25;
}
}
//ok, let's do some funky things with the ball.
function moveBall() {
if (playing) {
_root.ball._y += ball_y;
if (_root.ball._y<=0 || _root.ball._y+10>=h) {
ball_y *= -1;
}
_root.ball._x += ball_speed;
if (_root.ball.hitTest(_root.enemy) || _root.ball.hitTest(_root.player)) {
if (ball_speed<max_speed && ball_speed>-max_speed) {
ball_speed *= -1.5;
} else {
ball_speed *= -1;
}
}
if (_root.ball.hitTest(_root.enemy)) {
ball_y = ((_root.ball._y)-(_root.enemy._y+25))*0.2;
}
if (_root.ball.hitTest(_root.player)) {
ball_y = ((_root.ball._y)-(_root.player._y+25))*0.2;
}
//any points scored?
if (_root.ball._x+10<=0) {
enemy_score_one += 1;
click_2_play("Enemy scored. Click to continue.");
textBoxes(player_score_one, enemy_score_one);
playing = false;
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
ball_y = 0;
ball_speed = 1.2;
}
if (_root.ball._x>w) {
player_score_one += 1;
click_2_play("You scored! Click to continue.");
textBoxes(player_score_one, enemy_score_one);
playing = false;
_root.ball._x = w/2-5;
_root.ball._y = h/2-5;
_root.ball_speed = -1.2;
ball_y = 0;
}
}
}
//let's make some AI, shall we?
function enemyMove() {
if (playing) {
stupidity = 7;
//okay, so if the ball is on his side, follow it...
if (_root.ball._x+10>=w/2) {
_root.enemy._y += (_root.ball._y-(_root.enemy._y+25))/stupidity;
}
}
}
//weird, onEnterFrame does nto work for this poop,
//so i just use setInterval.. You have more control anyways...
setInterval(moveBall, interval);
setInterval(controlPlayer, interval);
setInterval(enemyMove, interval);


If you use it please credit.
Oh and leave comments, thank you ^_^

Pong
i have a pong game that works fine until i call that movie file into another clip .. the ball just stops moving and i am too dumb to figure out wat is wrong with it

the code for the ball is on the first frame

_root.onEnterFrame = function() {
bal._x = getProperty(bal, _x)+val;
bal._y = getProperty(bal, _y)+valy;
};


can any one help me with this

Pong
im trying to make pong but first i just want to make a thing that makes the ball bounce off all the walls. i used a 600 by 400 template. w = the direction of the ball. when i test it the ball just goes through any wall. i had it working before but then it stoped. Whats wrong?
onClipEvent (load) {
xadd=2;
yadd=2;
w=1;
}
onClipEvent (enterFrame) {
if (w==1) {
if (_x==600) {
w=4
}
if (_y==400) {
w=2
}
_x += xadd;
_y += yadd
}
if (w==2) {
if (_y==0) {
w=1
}
if (_x==600) {
w=3
}
_x += xadd;
_y -= yadd
}
if (w==3) {
if (_x==0) {
w=2
}
if (_y==0) {
w=4
}
_x -= xadd;
_y -= yadd
}
if (w==4) {
if (_x==0) {
w=1
}
if (_y==400) {
w=3
}
_x -= xadd;
_y += yadd
}
}

Pong
Oki, so I'm writing a pong game for flash. I will freely admit that I'd probably trying to re-invent the wheel here, but it's for my own edification, so bear with me. I have everything working except for 1 detail, the ball is set to move a little faster, everytime it is succesfully hit by a paddle (using hitTest), this works fine except when the ball reaches such a speed (ball._x += 5 etc)that it basically jumps the paddle. The x position in frame A + speed means the x position in frame B is beyond the paddle, so no hitTest, even if the paddle is in the right position. The only solution I've come up with so far, is to make the increments as small as possible (ie: + 0.1) and increase the frame rate to something ridiculous like 300fps. Anyone have a better suggestion, as even this will eventually not work.

Pong
Ok i can mae the paddles and everthing else exept the one thing..

A ball

I need it o make i bounce off paddles and walls..

Any help

Becuase whn im done making my pong game ill change it to A Air Hocke game

Pong
was bored in class today

Pong Game
I am having plans for making a pong game in flash, but before anything, a couple questions should be answered.

1.) How could i make the ball bounce off in different directions depending on where it hit the paddle.

2.) How to make the computer. Lol

Im going to have it so that you can switch between different skins and stuff. I kinda suck actionscript-wise but I am alright with...well you know what i mean. Does anyone have an idea?

Pong As A Preloader?
I am using the game pong as a preloader a my site downloads. My question is - I have a enter button on stage- It appears when my scene is downloaded- but if the game pong is playing nobody can press the enter button till it goes to game over. Any ideas?

Pong Part 1
Wassup Flashkitters

Ok I have a couple of questions

1. Would someone pleez send me the actionscript for a bouncy ball movement (like in pong)
2. Teach me how to make it bounce when it hits either paddle or the top or bottem thx y'all

Help With Pong Game
hey, I have this pong game i want to make my footer, but the paddles are too big. I f cut them down, It's hard to - i have the fla attatched, and the swf is here


http://www.angelfire.com/rock2/drummersonline/pong.swf

How To Insert Pong .fla
HI i was wondering how to insert a pong fla into my original movie as its preloader. also how to i make it start the movie once the game ends? thanks

Pong Game
Hi, I haven't used Flash for ages, so to get me back into the swing of things I am doing....Pong, although I what I am trying to do isn't working.


Code:
onClipEvent (load) {
xspeed = 8;
yspeed = 8;
this._y= 200;
this._x= 255;
_root.dir=0;
}

onClipEvent (enterFrame) {
if (this._y <= 40) {
_root.dir = 0;
} else if (this._y>360) {
_root.dir = 1;
}

if (_root.dir = 0) {
this._y += yspeed;
_root.y += yspeed;
} else if (_root.dir = 1) {
this._y -= yspeed;
_root.y -= yspeed;
} else if (_root.dir = 2) {
this._y = this._y;
}

}


what this is ment to do is if the dir is 0 then the ball goes downwars and if dir=1 then the ball goes up. If the ball.y gets less than 40 the ball should change direction but doesn't. Any ideas of the problem?

Cheers, gaz.

Ping Pong
it's a ping pong game, it kinda sux

Pong Game
is there a tutorial out there on how to make a pong game, or an example fla, i have an idea on how to do this but i think the way i was thinking of doing it is much more complicated than it should be i am just making a simple one for a preloader for a large file of mine
thanks for the help

Pong Game
Hey is their any tutorials that teach you how to make pong games in Flash MX. I want to create one but need a tutorial.

Pong Engine
Ive only been making flash games for a short while now. I just wanted to make a simple pong game for my friend. However, I cant find any ActionScript or engines that have AI and stuff. Basically, Im looking for an engine that will keep track of score, that has enemy AI, and that has boundarys on the top and bottom wall. Also, when someone scores, the ball should spawn in the middle of the game. If anyone knows of an engine, or has, one it would be greatly appreciated if they could share it with me.
Thanks!

**EDIT** Also, If you have a Breakout Engine, it is also, greatly appreciated!

Copyright © 2005-08 www.BigResource.com, All rights reserved