39 Forum Posts by "davidgilbert"
At 10/27/14 02:11 PM, Brownbird77 wrote:At 10/27/14 09:33 AM, Gimmick wrote: Look up multidimensional arrays. Arrays within arrays; you can use those and x and y coordinates to specify the location of a tile.I've already had a look at different arrays.
I'm aware that you can use an array with other arrays inside it in order to simulate an invisible grid with rows and columns.
But I have no idea how to actually get the tiles into that grid. As far as I'm aware the array is just a bit of code and doesn't yet have actual x or y values.
I don't really understand how to code the tiles into the array.
If you have an array that traces:
"lava, lava, earth, lava,
lava, earth, earth, earth,
earth, earth, water, water,
earth, earth, earth, water"
How do you get actionscript to understand that the 'lava' parts of the array should correspond to a lava tile? And how does it know where on the stage that should actually go? Do you have to assign the array to a movie clip that you can then give x and y values to?
I've seen code snippets but I don't understand what they mean.
If you know of a good tutorial that explains exactly how it works, feel free to direct me to it :)
Thanks for the reply
~Bb
Usually the array elements represent the column followed by the row that corresponds to where the graphic is on the spritesheet, or some static number like -1 if the cell does not have a value. For example, if an inner array elements value is 00, that means that it represents the graphic at column 0 and row 0 on the spritesheet (aka the very top left of the graphics spritesheet). 10 would represent column 1 row 0, and 21 would represent column 2 row 1. This is reliant on setting the spritesheet in a grid like manner, with any tiles that are smaller than the cell size aligned to the top left corner of its current cell.
Now, when you are physically placing the objects in the nested for loop, you are going to have to extract the column and row from the array number so that you can know which graphic to extract. This can be done by accessing the current array elements value, dividing it by 10 and converting that number to uint for the column, and taking the remainder (mod) of the number divided by 10 and converting that to uint for the row.
You are correct in that you do not store the actual x and y values of the object in the array. Usually, the physical x and y coordinates of the object on the screen is set by multiplying the current column and row in the nested for loop by the tile size.
At 8/27/14 03:13 PM, egg82 wrote:At 8/27/14 02:16 PM, davidgilbert wrote: As2 is slower than As3.It is, but.. What?
Sorry, that comment was only supposed to be in response to halfblue3; I forgot to take out milchreis's quote.
At 8/27/14 06:16 AM, milchreis wrote:At 8/26/14 08:16 PM, halfblue3 wrote: another question, why is it a mistake to learn as2. because i find it easier to do the coding part using as2 than as3?That's interesting, easier in terms of what?
As2 is slower than As3.
At 5/22/14 03:36 PM, bkbatman wrote: Thank you very much, I'll start reading the book once I finish this movie. Coding on the timeline was a bad idea,
where I had to place all the code together. Now with me learning how to use class in Flash. I should be able to separate what each are for.
Foundation Game Design with Actionscript 3.0 and AdvancED Game Design with Flash (its sequel) discuss classes and game development. Neither of them use the timeline to code. AdvancED Game Design with Flash in particular covers a lot of topics which imo are confusing and/or sparsely documented online. I was starting to think that topics like bouncing off an angled surface was too complex for me until I read it.
At 5/18/14 09:50 PM, MetalBooster wrote: I made a small game in flash using AIR.The screen orientation is landscape.The problem is that when the user locks the screen and then unlocks it,the orientation has changed to potrait with only the center one-third part of the screen displaying the game and the rest having blank white area.
Even on trying to rotate the screen,it remains in potrait mode.
What should I do so that the game remains only in landscape mode.
Look for the <initialWindow> xml tag in the application.xml file(if you are using Flashdevelop) or nameOfApp-app.xml (if you are using Flash Professional). Add/edit the following code:
<visible>true</visible>
<fullScreen>true</fullScreen>
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
At 5/14/14 09:12 PM, Hero101 wrote:I also wouldnt mind doing colabs, but beware, I have NEVER finished a game and my time is rather limited.That'll definitely make people want to collaborate with you.....yeah.....
Actually, I applaud his honesty, it is a rare thing in todays society.
At 5/1/14 10:21 PM, Aprime wrote: Righttttt......... so
Mochimedia is down and I need an alternative for the leaderboard system.
There's Newgrounds yes, but you need to be logged in to submit your score... unfortunately.
Which wouldn't be good when on several different sites.Are there are good leaderboard systems like Mochimedia about? That are free?
I've done Googling, found nothing but one... which required you to pay.Recommendations?
Yes, Gamersafe has a free leaderboard, and it is pretty good, but it has a few problems. Firstly, I had to add some custom code to get it to work, which I did not have to do with the Mochimedia leaderboard, but it also allows users to submit a score without entering a name. You can find out how I edited the code to get it to work here incase you run into problems.
In some ways the Gamersafe leaderboard is better, because it supports air (although I have not actually tried that feature yet).
At 4/25/14 09:40 PM, davidgilbert wrote: I am getting a weird bug with Flash Ads. My latest game Fruit Slicer does not show any ad impressions, but it has 147 views. I realize that ad impressions might not be 1-1 with ad views but I would think that I would have at least a few ad impressions by now.
Have they changed the implementation of ads on newgrounds, or does it just take time to show ad impressions?
Here is a link to my game as well: http://www.newgrounds.com/portal/view/638162
Well, it looks like I have 17 ad impressions, all today. It seems odd, because Fruit Popper has 2,623 views, but it has 2,730 ad impressions. So I guess its working somewhat.
At 4/23/14 12:54 AM, Hero101 wrote: I am curious how those of you on this site go about distributing your games? Do you do it the time consuming way by doing it yourself with each site or do you use outlets like Flash Game Distribution? FGD I read requires you to have their API ads in them which is kind of lame if you already have a game with ads in it.
So fellow game makers, how do you guys distribute your games?
I create different versions of my game for kongregate, newgrounds, Flash Game Distribution, and mindjolt. Not having mochiads has left a void for me, because I used to use them and submit my mochi version to talk arcades game feed, but I will probably submit my Flash Game Distribution version to talk arcades. I will probably also create a version on Google Play and Amazon Appstore to fill mochi's void, but I will need to work on the game size to fit on mobile first.
I am getting a weird bug with Flash Ads. My latest game Fruit Slicer does not show any ad impressions, but it has 147 views. I realize that ad impressions might not be 1-1 with ad views but I would think that I would have at least a few ad impressions by now.
When I had submitted previous games, I remembered a video playing, and then clicking the play button, but now it just displays a play button with what looks like an ad in it, if that makes any difference.
When I test it, it indicates that ads are working, and under project management it says status: Approved under the Ad Status panel. Here is the code that I have been using to get the ads to go:
import com.newgrounds.*;
import com.newgrounds.components.*;
private var _flashAd:FlashAd;
public function FruitSlicer() {
flash.system.Security.allowDomain("*");
API.addEventListener(APIEvent.API_CONNECTED, onAPIConnected);
API.connect(root,"API ID", "Encryption Key");
}
function onAPIConnected(event:APIEvent):void {
if(event.success) {
trace("The API is connected and ready to use!");
} else {
trace("Error connecting to the API: " + event.error);
}
_flashAd = new FlashAd();
_flashAd.showPlayButton = true;
_flashAd.x = 275 -(_flashAd.width * 0.5);
_flashAd.y = 200 -(_flashAd.height * 0.5);
addChild(_flashAd);
addChild(_flashAd.playButton);
_flashAd.playButton.x += _flashAd.x;
_flashAd.playButton.y += _flashAd.y;
_flashAd.addEventListener(Event.REMOVED_FROM_STAGE, adFinished);
}
public function adFinished(event:Event):void {
removeChild(_flashAd.playButton);
_flashAd.removeEventListener(Event.REMOVED_FROM_STAGE, adFinished);
// start game
}
Have they changed the implementation of ads on newgrounds, or does it just take time to show ad impressions?
Here is a link to my game as well: http://www.newgrounds.com/portal/view/638162
At 4/23/14 06:55 PM, moynzy wrote: Another question about jumping.
If I want to jump, how do i jump
//heehe
if(player is touching ground)
if the upKey is pressed
grav - = jumpHeight (lets say jump height is -5)
this means grav will be -18 and there fore vY will be adding - 18 on to its self which means
the players y pos will be shooting up wards.
How to make the player come back?
Cheers guys :D
Much love !
I would not do grav -= jumpHeight. I would try vY += jumpHeight (but make jumpHeight a negative number). I think gravity might still pull it down after a while. Also, add gravity to vY every frame. But in your if statements try my code. I think this should only be set once though.
At 4/23/14 06:55 PM, moynzy wrote: private function fall(e:Event):void
{
yV += grav;
this.y += yV
}
Question is, that I can't turn back gravity on or am I doing it wrong.
//hehe
if the player hits the platform
{
//turn grav to 0?
//or yV to 0?
touchingGround
and do I increment players.y position -- so it looks like it's standing accuratelty
}
Since you are adding gravity to the players y position when he is not on the ground, I would try to subtract gravity from its y position to neutralize it.
At 4/24/14 06:10 PM, MSGhero wrote:At 4/24/14 05:32 PM, davidgilbert wrote: Is there a close button for the Newgrounds ScoreBrowser? If not, how am I supposed to continue my game after then user is done viewing the high score table?No, you have to make the "play again" button and manually removeChild the browser.
Ok, I will try that. Thank you for the advice.
Is there a close button for the Newgrounds ScoreBrowser? If not, how am I supposed to continue my game after then user is done viewing the high score table?
Here is the code I have so far for the high scoring table:
import com.newgrounds.*;
import com.newgrounds.components.*;
private var _scoreBrowser:ScoreBrowser;
public function submitScore():void {
//remove listeners and display objects
API.postScore("Fruit Slicer High Scores", score);
_scoreBrowser = new ScoreBrowser();
_scoreBrowser.scoreBoardName = "Fruit Slicer High Scores";
_scoreBrowser.x = 275 -(_scoreBrowser.width * 0.5);
_scoreBrowser.y = 200 -(_scoreBrowser.height * 0.5);
_scoreBrowser.period = ScoreBoard.ALL_TIME;
_scoreBrowser.loadScores();
addChild(_scoreBrowser);
_scoreBrowser.addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
}
private function onRemoved(e:Event):void {
addEventListener(Event.ENTER_FRAME, gameLoop);
gameState = STATE_END_GAME;
}
The problem is, the ScoreBrowser does not seem to have any properties similar to showPlayButton and playButton that I can addChild (both of which are in the FlashAd class) to allow the user to close the high score table and replay the game.
Should I just add my own close button to the game and continue when it is clicked? Just for reference, here is what my high scoring table looks like; I am not receiving any errors when I preview it on newgrounds:
At 4/11/14 01:27 PM, davidgilbert wrote:At 4/10/14 07:38 AM, amaarweb wrote: I made a game.. and looking for instant publish portals like newgroundsmindjolt
here is my game link ..
http://www.newgrounds.com/portal/view/637198
hope u know other big sites like newground where i can get some views for my game
have a nice day
Sorry, forgot to add that it is not instant, but in my experience it will offer you more ad impressions than newgrounds. Also, I would try flashgamedistribution's manual submit button. It has a lot of instant publish portals.
At 4/10/14 07:38 AM, amaarweb wrote: I made a game.. and looking for instant publish portals like newgrounds
here is my game link ..
http://www.newgrounds.com/portal/view/637198
hope u know other big sites like newground where i can get some views for my game
have a nice day
At 4/7/14 01:34 PM, davidgilbert wrote: private function checkColl(char:Sprite, wall:Sprite):void {
var vx:Number = char.x + char.width / 2 - wall.x + wall.width / 2; /*this is assuming sprites registration point is kept at
its default (top left). if they are internally centered just do char.x - wall.x; vx and vy draws the x and y component of a
line between the center of the character to the center of the wall.*/
var vy:Number = char.y + char.height / 2 - wall.y + wall.height / 2;
if(Math.abs(vx) < char.width * 0.5 + wall.width * 0.5) {
// They overlap on the x axis. They must overlap on ALL axis for a collision to occur
if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5) {
//They overlap on the y axis; a square only has two axis so they overlap.
var overlap_X:Number = char.width * 0.5 + wall.width * 0.5 - Math.abs(vx);
var overlap_Y:Number = char.height / 2 + wall.height / 2 - Math.abs(vy);
/*Collision occurred on the axis with the least amount of overlap. I believe that this is true no matter how
complex the polygon is. The following code separates the objects; while the previous two if statements check to
see if they are colliding.*/
if(overlap_X >= overlap_Y ) {
if(vy > 0) {
char.y = char.y + overlap_Y;
//character is hitting bottom side of platform. Add overlap to char y pos to keep char below platform.
// set y speed to 0
} else { // end if(vy > 0)
char.y = char.y - overlap_Y;
/* character is standing on platform; set isOnGround Boolean to true; (no jumping when on ground) and
set y speed to 0. */
}
} else { // end if(overlap_X >= overlap_Y )
if(vx > 0) {
char.x = char.x + overlap_X;
// char has hit right side of platform e.g. platform is to the left of character; set x speed to 0
} else { // end if(vx > 0)
char.x = char.x - overlap_X;
// character has hit left side of platform; set x speed to 0.
}
} // end else (overlap on X axis}
} end if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5)
} // end if(Math.abs(vs) < char.width * 0.5 + wall.width * 0.5)
}// end public function checkColl(char:Sprite, wall:Sprite):void
Sorry, change var vx:Number = char.x + char.width / 2 - wall.x + wall.width / 2; to
var vx:Number = (char.x + (char.width / 2)) - (wall.x + (wall.width / 2));
and
var vy:Number = char.y + char.height / 2 - wall.y + wall.height / 2; to
var vy:Number = (char.y + (char.height / 2)) - (wall.y + (wall.height / 2));
and
change end if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5)
to //end if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5)
At 4/5/14 05:25 AM, PsychoZombii wrote: Ah, ok. I'll give these suggestions a try, and I'll post if I have any problems.
Thanks guys :>
If you are checking/resolving collisions between rectangle and squares, you can also use the Separating Axis Theorem (you can use it for more complex polygons, such as triangles (e.g. a slope), but it is more complex). SAT allows you to see exactly how much the objects are colliding and on which side they are colliding. It is also very efficient.
To use it, call this method every frame: checkColl(mainChar, wall);
private function checkColl(char:Sprite, wall:Sprite):void {
var vx:Number = char.x + char.width / 2 - wall.x + wall.width / 2; /*this is assuming sprites registration point is kept at
its default (top left). if they are internally centered just do char.x - wall.x; vx and vy draws the x and y component of a
line between the center of the character to the center of the wall.*/
var vy:Number = char.y + char.height / 2 - wall.y + wall.height / 2;
if(Math.abs(vx) < char.width * 0.5 + wall.width * 0.5) {
// They overlap on the x axis. They must overlap on ALL axis for a collision to occur
if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5) {
//They overlap on the y axis; a square only has two axis so they overlap.
var overlap_X:Number = char.width * 0.5 + wall.width * 0.5 - Math.abs(vx);
var overlap_Y:Number = char.height / 2 + wall.height / 2 - Math.abs(vy);
/*Collision occurred on the axis with the least amount of overlap. I believe that this is true no matter how
complex the polygon is. The following code separates the objects; while the previous two if statements check to
see if they are colliding.*/
if(overlap_X >= overlap_Y ) {
if(vy > 0) {
char.y = char.y + overlap_Y;
//character is hitting bottom side of platform. Add overlap to char y pos to keep char below platform.
// set y speed to 0
} else { // end if(vy > 0)
char.y = char.y - overlap_Y;
/* character is standing on platform; set isOnGround Boolean to true; (no jumping when on ground) and
set y speed to 0. */
}
} else { // end if(overlap_X >= overlap_Y )
if(vx > 0) {
char.x = char.x + overlap_X;
// char has hit right side of platform e.g. platform is to the left of character; set x speed to 0
} else { // end if(vx > 0)
char.x = char.x - overlap_X;
// character has hit left side of platform; set x speed to 0.
}
} // end else (overlap on X axis}
} end if(Math.abs(vy) < char.height * 0.5 + wall.height * 0.5)
} // end if(Math.abs(vs) < char.width * 0.5 + wall.width * 0.5)
}// end public function checkColl(char:Sprite, wall:Sprite):void
This is called an axis aligned bounding box, because it is using squares which are not rotated. One important thing to remember: if you have polygons which do not have axis (aka sides) which are at 90 degrees, you must project onto the axis normal. Actually, I did not project anything in this example because the x and y components of the motion vector are the same as its projections on the x and y axis, and its width and height are the same as its projections on the x and y axis.
If you are dealing with collision between complex polygons, I would use Box2d. But if all of your objects can fit in a square or rectangle bounding box, I would use the above method. This can be adapted to use with moving platforms.
At 3/30/14 10:09 AM, Nysix wrote: Thanks for the replies. I won't use Stencyl because there is 0 freedom of making something. I tried Flexil and the others but everything is just possible with Arrays which is good for a small stage... I guess i'll go back to flash as3 ... Does someone knows a good platformer tutorial? I'm learning programming incidentally and want to do a platformer as early as possible
I know this isn't free, but Advanced Game Design with Flash by Rex Van Der Spuy has (almost) a whole chapter covering a tile based platformer.
tl;dr - build your skills and get a clue. Something which it seems almost no one on these forums has.
I am not sure why you are being so rude to him, but it is unnecessary. He was just asking a question.
Yeah, at first I had only seen his second post so it looked like he had. But when I clicked on the forum, instead of viewing it in the social feed, I realised.He didn't. He just made the same post twice (without the quote the second time) and added the edit message to it.At 4/4/14 12:40 PM, davidgilbert wrote:
Yeah, it would be nice if they added an edit button.
try echo "<img src=\"upload/" . $_FILES["file"]["name"] . "\" />";
Edit: Sorry, I didn't notice that you solved the problem in the previous post.
At 4/2/14 09:34 PM, Aprime wrote:At 4/2/14 05:05 PM, deckheadtottie wrote:So I got it to work outside the php tag, in a new one
Viewing your source code on upload_file.php displays this:
<img src='upload/<?php echo $_FILES["file"]["name"] ?>' />
But when I try to implement it in the actual script
echo '<img src="upload/. $_FILES["file"]["name"]" />';
It doesn't work. Not entirely sure how to adjust it according
Please help, thank you!
try echo "<img src=\"upload/" . $_FILES["file"]["name"] . "\" />";
At 4/2/14 01:50 PM, Aprime wrote: HTML5 and it turns black... that's all I know about it
I apologize for my ignorance, but what does "HTML5 and it turns black" mean?
At 3/31/14 10:28 AM, GeoKureli wrote:At 3/31/14 10:05 AM, davidgilbert wrote: You draw lines/curved lines in illustrator and flash. The points connect line segments, but you are not drawing points.A line is 2 points so, yes you are drawing points.
Two points determine a line, but two points in and of itself does not determine a line. It is kind of like an empty connect the dots puzzle.
But I see what you are referring to; I think we are having a semantics argument.
At 3/30/14 06:23 PM, GeoKureli wrote: Flash and Illustrator are vector based drawing programs. meaning you draw points rather than pixels
Why are you doing lines in photoshop and coloring it in in flash? why not just color it in Photoshop. Better yet, why not draw in flash, your drawing style uses solid line strokes, flash would really compliment that part of your work.
You draw lines/curved lines in illustrator and flash. The points connect line segments, but you are not drawing points.
At 3/17/14 03:17 PM, Barzona wrote:At 3/17/14 01:54 PM, davidgilbert wrote: Instead, they should be pushed into the levelArray property using a for loop in the class constructor. After you push level1, level2, and level3 into the array you can access them using levelArray[0] (which is the same thing as level1) levelArray[1] (same as level2) and levelArray[2] (level3).Actually, they were being pushed into the array in the part of the code you couldn't see (since it wasn't part of the topic). I do actually know that much about code.
Ok, but I think it is confusing to name the properties level1, level2, and level3, while also having another property named levelArray. If they are in the levelArray, I am not sure why they also need to be declared as class level variables; it seems superfluous. I think they could have been declared as local variables.
At 3/17/14 03:59 PM, MSGhero wrote:At 3/17/14 03:28 PM, davidgilbert wrote: Ok, excellent. So copypixels will not slow down an AIR app anymore? Does it matter if I have set the render mode to GPU or CPU?copyPx used to be the only way you could get an AIR app to run, idk why you say it's slow. GPU render mode makes your game run faster if you use GPU functions: draw() runs faster in CPU.
Ok that makes more sense. I thought the article was implying that blitting with copypixels was slow, but I think I misinterpreted the article. I have never built an AIR app, but that confused me because my experience building web games was that copypixels was the fastest way.
So I should use GPU render mode if I am using blitting and copypixels on mobile devices? I intend to only use the draw method a few times in the game, when I am placing the embedded tilesheet into the tilesheets corresponding bitmapdata.
At 3/17/14 03:06 PM, MSGhero wrote:At 3/17/14 02:20 PM, davidgilbert wrote: However, the first paragraph in this web page states that you should not have a single bitmap with blitting (which I am assuming is the same thing as my previous paragraph) because it is slow. But his later down in the page, on the paragraph that starts with 2) he states that copypixels is fast on mobile.Worry about optimization later. That article was written 3 years ago, and things have changed. AIR can handle blitting and vectors just fine now.
Ok, excellent. So copypixels will not slow down an AIR app anymore? Does it matter if I have set the render mode to GPU or CPU?
I am confused about how to optimize a tile based game for mobile, preferably without using starling, because it requires the wmode to be set to direct, which is not allowed on fgl.
I read a post here which said on slide 8 that you should keep your display list as simple as possible using BitmapData.copypixels(). I am assuming they mean only adding one or two bitmaps to the displaylist using addChild, and copying pixels to the few bitmaps on the display list using there corresponding bitmapdata.copypixels function (which is what I learned in AdvancED Game Design with Flash.
However, the first paragraph in this web page states that you should not have a single bitmap with blitting (which I am assuming is the same thing as my previous paragraph) because it is slow. But his later down in the page, on the paragraph that starts with 2) he states that copypixels is fast on mobile.

