Making a cannon in flash : AS2
- citricsquid
-
citricsquid
- Member since: Jun. 25, 2005
- Offline.
-
- Send Private Message
- Browse All Posts (18,412)
- Block
-
- Forum Stats
- Member
- Level 23
- Blank Slate
Programming is the art of solving a solution with the language you're using, a lot of programming is figuring out how something will happen within the language. If you know enough AS to build particle effects and you're "Programming for armor games" you know enough to work out how to use trigonometry to build a cannon with actionscript.
You should accept you're very new to AS and you know nothing and learn from there, not dive in, copy and paste some code and claim you're an AS expert programming for Armorgames. Shouting at Gust and the more intelligent members of here is going to get you nowhere.
- zedd56
-
zedd56
- Member since: Aug. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
At 10/7/08 02:19 AM, bioman3wars wrote: i dunno anything about it but i do do flash. i just started and dont no nythin about it.
Give me one good reason for posting this. Don't post useless things, it's a good start to getting hated.
As for you, fatkidwitajetpak. You say you can't work the meter, but you made my respect meter for you go down fairly quickly.
/lame.
But seriously. You copy-paste codes and "customize" them?
Basically you download somebody else's engine and then fill in the variables. Not cool, man. That's not even programming anymore.
You are learning "Advanced Coding" and apparently coding for armor games, when you can't do this cannon test? I've seen some pretty damn good shit come from armor games, and you better hope your graphic skills are crazy good, because if you can't code this meter, you're probably not going to last very long on AG's roster.
Also, i gave you a bit of code. Somebody else fully made the entire thing for you and somebody else explained it. El-Presidente gave you even more code, and explained basic trigonometry for you, and you still can't do this? To me, it looks like you're going to keep badgering us until we end up giving you the entire code.
Seriously, man. Use logic. Use your knowledge. Use google. No fucking joke, there, either. Be a little resourceful, and try to figure it out. Besides, figuring it out yourself is the only way you will truly be able to understand it inside out anyways.
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
You should accept you're very new to AS and you know nothing and learn from there, not dive in, copy and paste some code and claim you're an AS expert programming for Armorgames. Shouting at Gust and the more intelligent members of here is going to get you nowhere.
I do accept I know nothing about coding.. thats why i want to learn!
Look, here is how I got to be a programmer for a game being sponsered by armorgames.
A guy named THEMILLZ contacted me asking for help on his game Murder Ball. I said I would be glad to help him. I have programmed the ball bouncing around everywhere, now I just need to understand how to make a proper cannon.
I dont care if you dont believe me about armorgames or not. What I do care about is if someone can explain to me about coding a cannon. I need some code, however, simply because I need some understanding on what to type.
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
At 10/7/08 04:15 PM, zedd56 wrote:
As for you, fatkidwitajetpak. You say you can't work the meter, but you made my respect meter for you go down fairly quickly.
why lol? Cause I got into an argument with some people? Alright whatever.
Well anyway, I do appreciate you helping me with this, but please do not make stupid assumptions of the way I code. I code by getting coding, and learning everything I can do with it. For example... Lets say I have a bal and I want it to multiply into 2. I figure that out, and then mess around with it to make it multiply into 4 and drop down to the ground.
I am just starting this code stuff out, so I need some LINKS.
I will post a pic of the game once I get home.
- Rustygames
-
Rustygames
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 19
- Programmer
Everyone is arguing over who is a good programmer and who isn't.
Insecurity at it's finest :)
- Matt, Rustyarcade.com
- Musician
-
Musician
- Member since: May. 19, 2005
- Offline.
-
- Forum Stats
- Member
- Level 04
- Blank Slate
At 10/7/08 10:05 AM, GustTheASGuy wrote:At 10/7/08 09:46 AM, FatKidWitAJetPak wrote: I got codes from online and then learned how to use them. Then I used my own custom coding to do it all.That's pretty much copypasting.
Oh shut up. No it's not.
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
- El-Presidente
-
El-Presidente
- Member since: Jun. 2, 2005
- Offline.
-
- Forum Stats
- Member
- Level 27
- Blank Slate
FKWJP, it's the truth that Gust and Liam are good coders, even if Gust thinks I'm a total dumbass, I think he may have even sunk his respect for you below mine [if possible]. You can't keep switching between calling yourself a coder and a non-coder. If you can't figure out how to do this, you have no right to call yourself a coder. Think about how a slider works, it's the difference from the left to the bar on it. So just compare the two _x's...JEEZ! Or even put the slider bar inside the slider and then just take the _x position in general [if it's registered on the left]. Just admit to your non-existent coding ability and listen to us. I stated the solution like half way through the last page.
MY E-PENIS IS BIGGER THAN YOURS
8=================================>
...and this is my fag...
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
Ok ok.. i will try to do this. Here is a picture of the game of any of you are interested. The red things are the cannon and they shoot out one ball each that bounce around the stage and kill enemies. There are 50 levels. You control the mouse with your cannon and click to shoot. How does it look so far?
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
The fact is you're making a game with a guy and you intend to get it sponsered by Armor Games, this does not mean you are making a game FOR them, and also please don't ask me to make particle effects to try compare my skill to yours because I am not wasting my time. We have all made particle effects when we were learning to AS (fire, sparks, random crap, whatever) and they are not difficult.
Sup, bitches :)
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
At 10/7/08 08:06 PM, liaaaam wrote: The fact is you're making a game with a guy and you intend to get it sponsered by Armor Games, this does not mean you are making a game FOR them, and also please don't ask me to make particle effects to try compare my skill to yours because I am not wasting my time. We have all made particle effects when we were learning to AS (fire, sparks, random crap, whatever) and they are not difficult.
They sponsor him all the time. And I am making particle effects with a program called FUSE. It is completley different than making them using AS2. Some of the effects are made using AS2. I am just saying that I have worked on this particle effects project now for 2 months and wont take crap from anybody. I mean, obviously this game has some sort of potential. The intro sucks and needs to be changed into better graphics and I need to clean it up a bit, but so far people have stated the game has some really neat effects. It is a game that is supposed to show how Algebra and Geometry can be used in Flash.
Here is the particle game so far, in case you wanted to see what I meant. I am proud of it and think it will at least get daily 2nd place.
http://spamtheweb.com/ul/upload/051008/7 5814_particle.php
So anyway, I have looked at the cannon information and have made the cannon at least move lol. Well, back to the drawing board to try to make it shoot.
Thanks for all of your help and I hope to meet someone in person who can actually teach me how to learn and memorize coding.
- liam
-
liam
- Member since: Dec. 11, 2004
- Offline.
-
- Send Private Message
- Browse All Posts (14,243)
- Block
-
- Forum Stats
- Member
- Level 22
- Blank Slate
At 10/7/08 09:43 PM, FatKidWitAJetPak wrote: It is a game that is supposed to show how Algebra and Geometry can be used in Flash.
Lol? Algebra is VARIABLES, I did ALL my GCSE algebra homework in Flash about 3-4 years ago.. and geometry is shapes, so OF COURSE a VECTOR BASED PROGRAM will use geometry -.-
Sup, bitches :)
- zedd56
-
zedd56
- Member since: Aug. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 14
- Blank Slate
FKWAJP. Sorry, as it turned out, i HAVEN'T lost any respect for you.
I read your statement wrong, thinking you downloaded code and customized it, when in fact you read code to understand it, then rewrote it. You worded it strangely.
Sorry 'bout that.
Screenshot looks pretty decent.
Let's de-derail this thread and get back to the game, shall we?
This childish flamefest is full of comments about peoples' status as a coder and such.
stop? That'd be nice.
Now, fkwajp, tell us, where exactly are you atm? Have you worked out the cannons? Or was that the only problem?
- ProfessorFlash
-
ProfessorFlash
- Member since: Oct. 6, 2007
- Offline.
-
- Forum Stats
- Member
- Level 32
- Programmer
At 10/7/08 09:43 PM, FatKidWitAJetPak wrote: Here is the particle game so far, in case you wanted to see what I meant. I am proud of it and think it will at least get daily 2nd place.
http://spamtheweb.com/ul/upload/051008/7 5814_particle.php
That's not a game. It's a demo that shows "pretty" things. I'll eat my pants if that gets daily 2nd.
You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
At 10/8/08 06:59 AM, ProfessorFlash wrote:At 10/7/08 09:43 PM, FatKidWitAJetPak wrote: Here is the particle game so far, in case you wanted to see what I meant. I am proud of it and think it will at least get daily 2nd place.That's not a game. It's a demo that shows "pretty" things. I'll eat my pants if that gets daily 2nd.
http://spamtheweb.com/ul/upload/051008/7 5814_particle.php
Ill take that bet! SO if it does get placed, you will eat your pants. If it doesnt, however, I will eat my pants.
Expected on youtube.
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
Let's de-derail this thread and get back to the game, shall we?
This childish flamefest is full of comments about peoples' status as a coder and such.
stop? That'd be nice.
Now, fkwajp, tell us, where exactly are you atm? Have you worked out the cannons? Or was that the only problem?
Ok. THEMILLZ and I have gotten everything planned and worked out. I have the physics to make the ball bounce around the screen, which is the main part of the game. I have gotten the cannons to move. Now I just need to apply coding to the power bar and make the ball with physics in it shoot out of the cannon. I probably will have to apply basic trig.
- FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
OK!!! I think I got it figured out. I used this coding. I typed in what I put in for each movie clip, and what I put in for each frame. Like whatever code is under FRAME 1 is going to be in FRAME 1. I also included the instance names and everything.
So does it look right to you?
frame 1 {
_root.onLoad = function () {
cannon._rotation = 90;
barBounds = bar.getBounds(_root);
var v4 = 1;
var v3 = 0;
var v6 = 1;
var v7 = false;
var v2 = 0;
var v5 = false;
};
_root.onEnterFrame = function () {
if (Key.isDown(38)) {
cannon._rotation -= 2;
}
if (Key.isDown(40)) {
cannon._rotation += 2;
}
if (cannon._rotation > 90) {
cannon._rotation = 90;
}
if (cannon._rotation < -5) {
cannon._rotation = -5;
}
if (peg._x <= barBounds.xMin) {
propel = 1;
savepropel = propel;
}
if (propel == 1) {
peg._x += 3;
}
if (peg._x >= barBounds.xMax) {
propel = -1;
savepropel = propel;
}
if (propel == -1) {
peg._x -= 3;
}
if (propel == 0) {
++peg._x;
--peg._x;
}
if (Key.isDown(32)) {
propel = 0;
speed = (peg._x - barBounds.xMin) / 16;
duplicateMovieClip('ball', 'ball' + i, i);
++i;
fired = true;
}
if (!Key.isDown(32)) {
if (fired == true) {
fired = false;
propel = savepropel;
}
}
};
}
movieClip 2 {
}
movieClip 4 {
}
instance ball of movieClip 4 {
onClipEvent (load) {
grav = -6;
speed = _root.speed;
_rotation = _root.cannon._rotation;
if (_name == 'ball') {
_x = -2000;
} else {
_x = _root.cannon._x;
_y = _root.cannon._y;
}
}
onClipEvent (enterFrame) {
_y = _y + grav;
++grav;
if (_rotation > 180) {
_y = _y + speed * Math.cos(0.0174532925199433 * _rotation);
_x = _x - speed * Math.sin(0.0174532925199433 * _rotation);
} else {
_y = _y - speed * Math.cos(0.0174532925199433 * _rotation);
_x = _x + speed * Math.sin(0.0174532925199433 * _rotation);
}
if (_x > Stage.width or _x < 0 or _y > Stage.height or _y < 0) {
this.removeMovieClip();
}
}
}
movieClip 6 {
}
movieClip 8 {
}
movieClip 10 {
}
}
I did this based on the cannon that was featured on page one.
- Xaotik
-
Xaotik
- Member since: Mar. 26, 2008
- Offline.
-
- Forum Stats
- Member
- Level 15
- Programmer
FKWAJP... That looks like something similar to my original cannon code before I re-did it, if you want the base code here it is but my tutorial has a much better code:
Frame 1:
_root.onLoad=function(){
cannon._rotation=90
barBounds=bar.getBounds(_root)
var propel=1
var speed=0
var i=1
var fired=false
var savepropel=0
var fire=false
}
_root.onEnterFrame=function(){
if(Key.isDown(Key.UP)){
cannon._rotation-=2
}
if(Key.isDown(Key.DOWN)){
cannon._rotation+=2
}
if(cannon._rotation>90){
cannon._rotation=90
}
if(cannon._rotation<-5){
cannon._rotation=-5
}
if(slider._x<=barBounds.xMin){
propel=1
savepropel=propel
}
if(propel==1){
slider._x+=3
}
if(slider._x>=barBounds.xMax){
propel=-1
savepropel=propel
}
if(propel==-1){
slider._x-=3
}
if(propel==0){
slider._x++
slider._x--
}
if(Key.isDown(Key.SPACE)){
propel=0
speed=(slider._x-barBounds.xMin)/16
duplicateMovieClip("ball","ball"+i,i)
i++
fired=true
}if(!Key.isDown(Key.SPACE)){
if(fired==true){
fired=false
propel=savepropel
}
}
}
Cannon Ball-
onClipEvent (load) {
grav = -6;
speed = _root.speed;
_rotation = _root.cannon._rotation;
if (_name == "ball") {
_x = -2000;
} else {
_x = _root.cannon._x;
_y = _root.cannon._y;
}
}
onClipEvent (enterFrame) {
_y+=grav
grav++
if (_rotation>180) {
_y += (speed*Math.cos(Math.PI/180*_rotation));
_x -= (speed*Math.sin(Math.PI/180*_rotation));
} else {
_y -= (speed*Math.cos(Math.PI/180*_rotation));
_x += (speed*Math.sin(Math.PI/180*_rotation));
}
if (_x>Stage.width or _x<0 or _y>Stage.height or _y<0) {
this.removeMovieClip();
}
} - FatKidWitAJetPak
-
FatKidWitAJetPak
- Member since: Jul. 28, 2007
- Offline.
-
- Forum Stats
- Member
- Level 29
- Musician
Yeah I tried your tutorial and it worked out just fine. I really appreciate your help in this.


