Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411372 Posts in 69353 Topics- by 58405 Members - Latest Member: mazda911

April 13, 2024, 03:32:03 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
  Show Posts
Pages: 1 ... 24 25 [26] 27 28 ... 34
501  Developer / Technical / Re: flash (the ide not the language) on: August 23, 2008, 10:16:23 AM
Oh right sorry about that actor is just this...


Code:
package {
import flash.display.Sprite;
import flash.events.*;
import flash.events.Event;

public class Actor extends Sprite {
var velx:int;
var vely:int;
}
}

Its not important for the part I have in there just for another part I coded involving platforms...

2.  I originally wrote the update functions as each having there own on frame load event listener but then I took the individual ones out and put them all into the one main update function but figured I should still pass the event around.

3.  Sorry bad habit from C I guess

4.  Oh right it still seems to compile fine though
502  Community / Bootleg Demakes / Re: [FINISHED] Thieving Raccoon on: August 23, 2008, 10:09:06 AM
That is so awesome.  I would love to see the code to something like that.
503  Developer / Technical / Re: flash (the ide not the language) on: August 23, 2008, 09:17:22 AM
Ok then I must be doing something way wrong... Here is the source with as much stuff taken out so as to replicate the problem...

Code:
package {
import flash.display.*;
import flash.events.*;
import flash.utils.Timer;
import flash.text.TextField;

public class ZombieGame extends MovieClip {
var zombies:Array = new Array();
var blocks:Array = new Array();
var pickups:Array = new Array();

var zombieTimer:Timer;
var player:Player;
var timer:Timer;
var frames:int;

var blood:Sprite;


public function ZombieGame():void {
init();
}


function init():void{
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
stage.addEventListener(Event.ENTER_FRAME, update);

player=new Player();
player.x=100; player.y=100;
addChild(player);

var i:int;
for(i=0;i<8;i++){
var zombie:Zombie = new Zombie(player,blood);
zombies.push(zombie);
addChild(zombie);
}



timer=new Timer(1000);
timer.addEventListener(TimerEvent.TIMER,fps);
timer.start();


}


function fps(TimerEvent){
fpsOut.text="frames: "+frames;
frames=0;
}

function keyPressed(key:KeyboardEvent){
player.controls(key.keyCode);
}

function keyReleased(key:KeyboardEvent){
player.released(key.keyCode);
}

function update(called:Event){
frames++;



var i:int;
var j:int;
player.update(called);
for(i=0;i<zombies.length;i++){
zombies[i].update(called);
}

}


}
}

That is the Document class or whatever.  And now here is the zombie class...

Code:
package {
import flash.display.Sprite;
import flash.events.*;
import flash.events.Event;

public class Zombie extends Actor {
var player:Player;
var blood:Sprite;
var respawn:int;

function Zombie(aplayer:Player, ablood:Sprite){
player=aplayer;
blood=ablood;
die();
}

function update(Event):void{
respawn--;
if(respawn==0)visible=true;
if(respawn<0){
velx = (Math.random()*5)-3;
vely = (Math.random()*5)-3;

if(player.x<x)velx--;
if(player.x>x)velx++;
if(player.y<y)vely--;
if(player.y>y)vely++;

x+=velx;
y+=vely;
}
}

function die():void{
var side:int;
side=(Math.random()*100)%4;
switch(side){
case 0: x=-50; y=Math.random()*400; break;
case 1: x=600; y=Math.random()*400; break;
case 2: x=Math.random()*550; y=-50; break;
case 3: x=Math.random()*550; y=450; break;

}

respawn = Math.random()*180+30;
visible=false;

}
}
}

and finally here is the player...
Code:
package {
import flash.display.Sprite;
import flash.events.*;
import flash.events.Event;

public class Player extends Actor {
var speed:int;
var gun:Gun;

public function Player():void {
init();
}


function init():void {
speed=10;
}

function update(called:Event):void {
x+=velx;
y+=vely;
}

function controls(keyCode:int):void {

if (keyCode==38) {//up
vely=speed*-1;
} else if (keyCode==40) {//down
vely=speed;
} else if (keyCode==37) {//left
velx=speed*-1;
} else if (keyCode==39) {//right
velx=speed;
}

}

function released(keyCode:int):void {
if (keyCode==38) {//up
if(vely==speed*-1)vely=0;
} else if (keyCode==40) {//down
if(vely==speed)vely=0;
} else if (keyCode==37) {//left
if(velx==speed*-1)velx=0;
} else if (keyCode==39) {//right
if(velx==speed)velx=0;
}
}
}


}

What happens is everything is going fine before the zombies come on screen... Running at a nice 30 fps.  Then as soon as a couple appear the fps drops to a steady 21 fps from it's 30 and never goes back up again unless all the zombies stack on top of each other...

I really appreciate all the help guys!

Also if the number of zombies is 8 or 30 the fps still drops to a steady 21 and then doesn't change.  Also no matter what the starting fps it still drops to 21.  This is of course all tested by me pressing command return.  I don't know if there is a different way your supposed to do these things...
504  Developer / Technical / Re: flash (the ide not the language) on: August 22, 2008, 02:38:50 PM
Quote
Hm, why would you like to do that?
I mean you can wirte with AS3 code to the timeline .. but I would like to know an example where you would like to do that?!
no I meant the oppisite of that but it's ok I figured it out.  You just have to name the class the same thing.

Quote
Finally, arrays can't be of fixed types, and the only unobvious thing that i can think of that slows flash down is excess function calls. For some reason they are rather CPU expensive, though in all honesty you shouldn't worry about optimisation until you need to. It's hard enough to create a laggy game, and once you get that (if you get that) then you can optimise.

well you see there is the problem I'm having.  Right now I have the player, 1 non moving block, 1 zombie, and 2 bullets max on the screen right now.  Whenever I fire off even 1 bullet the game drops from 30fps to 20 fps.  Same thing happens if I add 1 more zombie and don't fire any bullets.  It's like whenever I add more then 1 or 2 moving objects on the screen the framerate drops by like 10.  That's not normal is it?  I'm moving the objects around by just saying x+=velx; and y+=vely; that's how I'm supposed to do it right?  Anyone know what that might possibly be.  At first I thought it was the collision detection but turning that off doesn't change anything.  It's weird...  I'm adding these images just to the stage is this bad?  Should I just have 1 sprite that I call actors or something add that to the main and then add all my sprites there?
505  Community / Procedural Generation / Re: The Blood Red Square on: August 21, 2008, 09:38:52 AM
Quote
1. to start your player somewhere more central on the screen if possible (currently you start top left on a new game/after death), because its a bit hard to see hidden up in that corner AND you get instant death from 50% of your control options (up/left=die).

yeah I see what you mean there in the next version I won't do that. 

Quote
2. Its not super obvious that the walls kill you, a cheap solution might be to run a green line around the outside of the play area - that way you have a clear language that green is bad to touch (as you already know from the rules that green blocks are to be avoided.

oh ok I didn't realise that.  I mean it's obvious to me because I programmed it but I can see why it wouldn't actually be.  I'll try to add that in next time too.

Quote
I got into first place with 71, tied with the second place Smiley
Cool game! If you ever make a sequel, I suggest the green blocks move back and forth Smiley
Nice work, good game  Cool

thanks!  I do plan on making a sequel and moving blocks is one of the things I plan on doing.  I already have that code working actually Smiley

Quote
Nice!

Challenging little game you made there.

Thanks!  yeah for some reason for arcade style games like that I hate it when they have a slow build up.  I don't know I guess i just get bored fast...
506  Developer / Technical / Re: flash (the ide not the language) on: August 21, 2008, 09:35:50 AM
Quote
3. when you code with AS3 you put your code in the document class. Check the Thread from Cagey.
Also this tutorial on http://www.gotoandlearn.com.

OK I think I phrased my question wrong.  Because of reading that thread I understand how to move stuff out of my first frame of the movie using document class.  What I still don't understand is how to not put code inside the frames of my movie clips.  How do I link the code to the movie clips in flash.


Quote
1. Flash is not an Illustrator Application, thats why you can draw many stuff in one Layer. Maybe what would be handy for you is the "Draw To Object" Function.
Select your drawing Tool and then the Key "J", or the Icon on the Toolbar with the square with the circle in it. So every time you paint it creates an Object Group.
Ok I'll try that.

Quote
a. hundreds of movieclips addet to the stage
b. more then one onEnterFrame event
c. many moving objects with filters/alphas (use BitmapData for such an action)

cool thanks those first two where both things i was planning on doing but I know how to get around them.

Quote
The biggest reason for not using the Flash CS3 IDE for coding is because it lags like a bitch when the code gets slightly bigger than absurdly short.

Do you mean when coding a lot the ide lags or when you code a lot in the actual frames the movie will lag a lot?

Quote
Finally, arrays can't be of fixed types, and the only unobvious thing that i can think of that slows flash down is excess function calls. For some reason they are rather CPU expensive, though in all honesty you shouldn't worry about optimisation until you need to. It's hard enough to create a laggy game, and once you get that (if you get that) then you can optimise.

Ok cool I'm fine with arrays not being fixed types as long as it means I don't have to cast everything when i take it out.

Quote
Heh, for much the same reasons I find Flash to be a lot more convenient and intuitive. Easily being able to draw lines all over each other and then click and delete the bits of line I no longer need is nice.
Yeah I think it's more the fact that I'm not a good artist at all that makes me not like the flash interface.  I can handle inkscape because I just have to lay down circles and squares and deform them a bit.  I never really use the actual pen tool in inkscape.  So yeah... that's probably why.

Quote
An Array is untyped (not ints or strings!).
ok cool I just always saw people putting what I guess you would call primitives in them  in all the tutorials so I didn't know you could stick in anything.

Quote
Or use haXe. It has properly typed arrays and is the superior language all around.

haXe looks pretty crazy but I'll probably stick to learning flash first.

Thanks everyone for all the help!
507  Developer / Technical / flash (the ide not the language) on: August 21, 2008, 12:35:00 AM
Ok so I recently got my hands on a copy of flash cs3 for cheap.  Anyways I've been fooling around with it and having lots of fun.  It seems very easy to write simple games and I'm not having difficulties with the coding really.  There are some things that I do not understand about the ide and the format in general...

1.  I'm used to inkscape and to me it seems like the flash drawing utilities suck.  When I draw a square I want to be able to select that square as one object (drawing use of the term not programming wise or anything).  In inkscape it's kinda like every shape has it's own layer if you know what I mean but I can't really seem to do that in flash besides physically creating a new layer in flash for every shape I draw.  Is flash meant to do this kinda drawing stuff?

2.  What kinda fps should I be shooting for?  I'm not used to having my stuff running in a browser so my thought is 60 fps but that's obviously too fast for a browser.  So what like 30 or something?  The default 12 seems like it would be to slow, is it?

3.  I'm not really sure where to put my code.  So far I have been just putting it into the first frame.  I just figured out about document class so that solves the problem for the whole project but what about my movie clips.  How do I link code in external files to them.  Also is there any reason besides opinion (does it run faster use less memory etc.) for putting stuff in other files besides just in the frames of the flash project.

And then two general programming questions.

1.  How do I create an array of a specific type of objects.  I can make one but it always is just of ints or strings or something.  I want to say an array of enemies or something so I don't have to cast when taking them out.

2.  Anything that i should avoid that will really slow down my code?

Thanks for all your help guys!
508  Community / Procedural Generation / The Blood Red Square on: August 18, 2008, 08:57:04 AM
Ok so I had an entry into the procedural competition which I finished (pretty much) before the deadline but unfortunately when it was done and I played it I realized it just wasn't much fun at all...

Since then I have started learning flash.  In thinking about what to do I wanted to I still wanted to finish a procedural game and post it, so here it is.  Note this is only the second game I have ever made in flash so constructive comments would be nice but I know it's simple and all.

http://www.kongregate.com/games/nitsud/the-blood-red-square

if anyone wants to see the first one it's here...

http://www.kongregate.com/games/nitsud/bagels-and-taxis
509  Developer / Technical / Re: NINTENDO DS: All Tigers Please Read! on: June 06, 2008, 03:50:27 PM
Quote
Something framework-ish for making DS-portable games would be real neat though. I'm really not into DS homebrew stuff at all and I don't know what already exist, but, like, making DS games that will also run on PCs makes more sense to me than the other way around.

You can use PAlib which is framework ish in the sense that it's not ARM programming.  I used that to make a couple of games for the DS it's fun and pretty easy.  There's already quite a few cool homebrew games out there for the DS and homebrew equipment isn't expensive either.


As to getting the DS to run .exe's as other people have said it might as well be impossible.
510  Community / Procedural Generation / Re: run and gun on: May 21, 2008, 09:15:42 PM
Quote
THE RAINBOW JUSTICE GUN.

Basically  yeah that's what happens when you randomly generate the color of the bullets... also as I don't have a name that's threatening to be it... possibly

Rainbow Guns of Justice?

Quote
That explosion looks fantastic.

Thanks!  I really appreciate all these comments. I don't actually think they look that great in stills like that but yeah it's all animated nicely and all.  Also they are procedurally generated!

So I have the flow of the game worked out and all implemented so from now until the end it's just a matter of polishing gameplay and graphics.  Here is how it goes down...

1.  You enter a word to generate a game
2.  this generates a gravity and friction force and a terminal velocity for this game.  These will be constant for all levels withen the game.  You then get your two starting guns which have size, density, damage, reload time, and speed all proceduraly generated.
3.  The first level is generated with pg platforms and pg placed enemies with random velocities who's health adds up to a constant.  You can jump with j shoot with k and switch guns with l.
4.  If all the enemies are defeated before you die you go to the in between stage screen where a new gun is generated for you.  You can choose any two of the three guns (the two you had in the last stage and one new one) to carry on with you to the next stage.
5.  Increase the difficulty a bit and generate a new level.
6.  When you die get your score posted along with the word that generated the whole game.  The same word will generate the same game for all people so you can share high scores for specific words.

Like I said it's pretty much all implemented but needs a lot of polish...  What do people think?  Any parts sound confusing or any thing really calling out to be added?

511  Community / Procedural Generation / Re: Last Colonists (shmup/music game) DEMO and SCREENS on: May 21, 2008, 07:52:06 AM
hm... well I'm on osx and I write quite a bit of java so I was pretty sure I had the newest java installed already.  Even so I reinstalled java 6 (that's the newest right they didn't sneak one past me?  Anyway I'm using firefox version 2.0.0.4 I so the browser is pretty new as well.  Still when I load the page at the bottom it says...

Applet ProceduralShooter notloaded

and there's just an x where it should be
512  Community / Procedural Generation / Re: Last Colonists (shmup/music game) DEMO and SCREENS on: May 20, 2008, 05:22:55 PM
I get a strange broken applet thing when I view your page which is really too bad as I would love to play this and use java to write my games as well!
513  Developer / Art / Re: show us some of your pixel work on: May 20, 2008, 02:21:50 PM
I like the idea but street fighter III probably has my favorite sprites in all of video game history...  needless to say I like the original more even though yours is great
514  Community / Procedural Generation / Re: run and gun on: May 19, 2008, 09:06:51 AM
ok then I guess that's what I'll hope for!

I didn't have my computer for last week so not to much work got done Sad .  I did change the graphics up a bit, fine tune some stuff, and added explosions when the bullets hit...




the explosions need to be toned down a bit as they get seriuosly crazy and you can't see what's going on at the moment.
515  Developer / Technical / Re: detecting collision on: May 11, 2008, 10:14:36 PM
yeah I know it's probably not the absolute best but it is the simplest I know of and it sure cuts down on the needed calculations.  Also you don't get the problems along the  boundaries as long as you specify that each object can be in multiple quadrants.  At least I don't see how...

Splitting the screen up into more then 4 areas is also what I was thinking of (I just suggested splitting it up into areas) but I didn't want to make my calculations over complicated Smiley
516  Developer / Technical / Re: detecting collision on: May 11, 2008, 07:39:11 PM
oh ok well sweet then!
517  Developer / Technical / Re: detecting collision on: May 11, 2008, 05:41:02 PM
Quote
Why not use an existing physics engine like Box2D or ODE?

I can see not using one of thse just because it's fun coding your own and less complicated if you want a simpler physics engine...

Quote
and dustin thank you.now I got it. Cheesy
(Iam using C/C++ with directX.)

you are welcome however if your using c++ it seems weird that you are getting slow down with only 50 by 50 objects.  Just as a test I tried it with my own code which like I said is not exactly like yours but still.  I managed to do about 500*500 rectangular collision detections (plus displaying, and stuff) at 30 fps in java.  It seems like there might be something wrong with your code that's slowing it down a ton.
518  Community / Procedural Generation / Re: MMORPG Tycoon on: May 11, 2008, 02:17:49 PM
for java if your using lwjgl then you should be able to do a very similar thing as it's still openGL.  Also, since the openGL routines are C++ it would be just as fast anyway...
519  Community / Procedural Generation / Re: run and gun on: May 11, 2008, 01:26:36 PM
ok So I'm nearing the stage where I'd like to get some feedback.  Here's the status


Graphically it sucks and looks horrible but hopefully that will get polished up when I have time

The mechanics are all done I think and I like the way they work

The level flow isn't done it's just level after level at the moment

The generation stuff all works but depending on the numbers sometimes it's much more fun then others.  This is what I need feedback on.  How to limit the generation numbers so that only the fun outcomes come out.  It would mainly mean playing and recording which setups of weapons/player movement configuration/levels you liked and which you didn't like.

Now here's what I'm wondering i can just release a demo but I feel like then people might have negative impressions of the game and not bother to play the final release which won't really be much like this release hopefully.  This is more just to test the mechanics and get my numbers right.  Because of this I would rather just have 1 or 2 people who I could email it to and they could tell me what was up.  Don't know which way you guys think is better/ if anyone is interested in doing it anyway.
520  Developer / Technical / Re: detecting collision on: May 11, 2008, 01:05:28 PM
um... well what language is it written in?  Also are you using hardware acceleration for the graphics?  If not it could easily be your rendering method slowing things down.  Even so if your using a fast language (like c/c++ etc.) it does seem slow for just simple no torque physics like that.  I know in my java game I don't have a physics detection going on exactly like your but it's pretty simlar in terms of speed usage I would imagine (100 or so things colliding with 10 or so other objects which would be roughly equivalent to 32 things colliding with 32 other things) and I seem to be able to pretty easily get constant 60 fps and java is slower then c/c++.  I know your video is in flash so if this is programmed in flash then I would imagine that is the main reason why your fps is low...

If you want general tips in how to handle collision detection faster then I would suggest splitting the screen up into areas.  For example divide the screen into 4 quadrants, everything in the upper left only needs to worry about collision with other things in the upper left etc. That kinda thing helps a lot because then instead of 32 objects colliding with 32 other objects (1024 collisions possible) you only have to check

1.  each object with the 4 quadrants worst case (32*4=128)
2.  each object with the others in it's quadrant assuming equal distribution (32/4*32/4*4=256) the 32/4 are the number of objects in each quadrant and there are 4 quadrants in total.

Those add up to 128+256=384 as apposed to 1024.  Again though I would make sure nothings wrong before making your code more complicated even if it's not that much.  You could be not adressing the real problem.
Pages: 1 ... 24 25 [26] 27 28 ... 34
Theme orange-lt created by panic