Recent posts by aenil333 on Kongregate

Flag Post

Topic: Game Programming / PHP and AS2

No, i told you the code to have one working but you gotta add it yourself sorry. If you dont have the required skill to simply add/modify this in your code then i dont see how you can progress in this way. You should read tutorial about php/sql and as3. (As2 is a waste of time imo)

 
Flag Post

Topic: Game Programming / PHP and AS2

just write it here

 
Flag Post

Topic: Game Programming / PHP and AS2

i dont use skype or any chatting device

 
Flag Post

Topic: Game Programming / PHP and AS2

forgot you wanted it for as2… that was as3 my bad but could still help you i think

 
Flag Post

Topic: Game Programming / PHP and AS2

Here is your magic code:

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;

private const phpUrl:String = "http://localhost/phpfolder/";
private var phploader:URLLoader;
private var phprequest:URLRequest;
private var statusBox:TextField;

private function Main() {
	statusBox = new TextField();
	statusBox.multiline = true;
	statusBox.height = 100;
	statusBox.width = 200;
	statusBox.background = true;
	statusBox.backgroundColor = 0xBBB444;
	statusBox.x = 412;
	statusBox.y = 660;
	statusBox.wordWrap = true;
	statusBox.text = "";
	addChild(statusBox);
}
private function loadURL(theUrl:String, param:String):void {
	phploader = new URLLoader();
	phprequest = new URLRequest(theUrl + param);
	phprequest.method = URLRequestMethod.POST;
	phploader.addEventListener(Event.COMPLETE, loadedData);
	phploader.addEventListener(IOErrorEvent.IO_ERROR, loadError);
	phploader.addEventListener(IOErrorEvent.NETWORK_ERROR, loadError);
	phploader.addEventListener(IOErrorEvent.VERIFY_ERROR, loadError);
	phploader.addEventListener(IOErrorEvent.DISK_ERROR, loadError);
	phploader.load(phprequest);
}

public function loadedData(e:Event):void {
//***Optional
	//var str:String;
	//str = e.target.data;
	//var index:int;
	//check for somethigng in the string
	//index = str.indexOf("word");
	//if(index != -1){
	//	trace("Word found [" + str.slice(index + 4,str.length + "] at index: [" + index + "]"));
	//	statusBox.appendText(str.slice(0,index));
	//}
	statusBox.appendText(e.target.data);
	statusBox.scrollV = statusBox.maxScrollV;
}
		
private function loadError(e:IOErrorEvent):void {
	statusBox.appendText(e.text);
	statusBox.scrollV = statusBox.maxScrollV;
}

As for your php file you should use prepare statement to protect from injection.

Here is your second magic code:

<?php
$mysqli = new mysqli("localhost","root","","flashspele");
if (mysqli_connect_errno()) {
	printf("Error: %s\n", mysqli_connect_error());
	exit();
}
$data1 = $_GET["username"];
$data2 = $_GET["password"];

$query = "SELECT username,password FROM users";

if ($stmt = $mysqli->prepare($query)) {
	$stmt->execute();
	$stmt->bind_result($user, $pass);
	$data = 0;
	while ($stmt->fetch()) {
		if ($user == $data1) {
			$data = 1;
			if ($pass == $data2) {
				$data = 2;
			}
		}
	}
	$stmt->close();
}
$mysqli->close();

if ($data == 0) {
	printf ("Username is incorrect.\n");
} else if ($data == 1) {
	printf ("Password is incorrect.\n");
} else if ($data == 2) {
	printf ("You are logged in.\n");
}
 ?>
 
Flag Post

Topic: Collaborations / Idea for a simple game similar to tic-tac-toe

i wouldnt personnaly name something tic tac toe… if no one ever did it ask yourself if the company is sueing them all when they do… just like tetris, bomberman, mario bross… and so on
dont wanna break your fun or anything, just saying :P (i saw you maybe wanted to sell the game for 1$ on mac or whatever platform… thats a big risk)

 
Flag Post

Topic: Game Programming / Why does this not work?

expression1 >= expression2

Operands
expression1:Object — A string, integer, or floating-point number.
expression2:Object — A string, integer, or floating-point number.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html#greater_than

 
Flag Post

Topic: Game Programming / Why does this not work?

try using like Pies > 99 (it wont use 99 just over it) that should simply solve it…

 
Flag Post

Topic: Game Programming / AS3 HitTest a level?

what i did once is name all the object in my generated world (even if yours is not you have to build it somehow) so i use the .name to name every object like this “Walkable, NotWalkable”, if the point hit a Walkable name can continue.. hope the idea help!

 
Flag Post

Topic: Game Programming / AS3 HitTest a level?

instead of checking if the player hit every graphic of an array you can use hittestpoint to check if the character hit something around him

 
Flag Post

Topic: Game Programming / How To Use Regular Expressions

if you want the first 5 numbers of a string, you do something like this: /[0-9]{5}/
if you want to search the 5 char and , then remove it, its something like this: /[0-9,]{5}/

/ / is used to parse the regex code, [] is a character set, {} is a quantifier.. Everything is explained there and you can also practice it: http://regexr.com/

 
Flag Post

Topic: Game Programming / [AS 3]Some Advice about Accessing objects in an Array

you have an error if you are trying to access with this die0.gotoAndStop(1+Math.floor(Math.random()*6);
since your array is dice not die… ;p

 
Flag Post

Topic: Game Programming / 2D Manager Engine

well there are two game made by the same person “littlegiantworld” so he probably use the same engine. But almost every tycoon game looks like the same. They probably use that idea as a general idea for making their games. Thats why the similitude between them and the kind of (not always) pixel art that come with it.

http://www.ehow.com/way_5296186_list-tycoon-games.html

 
Flag Post

Topic: Game Programming / getting image from a x y coordinate

yup getObjectUnderPoint was the solution… took some hours but FINALY lol

there is probably better solution but anyway, here is how im using maybe could give idea to others, its pretty simple actually:

for (var x = 0; x < stage.getObjectsUnderPoint(enemyNextMovePoint).length; x++) {
if (stage.getObjectsUnderPoint(enemyNextMovePoint)[x].name == “Ground”) { //do stuff here }
}

 
Flag Post

Topic: Game Programming / getting image from a x y coordinate

i think i might find a solution with this function but not totally sure how to use it yet

getObjectsUnderPoint(point:Point):Array
Returns an array of objects that lie under the specified point and are children (or grandchildren, and so on) of this DisplayObjectContainer instance.

 
Flag Post

Topic: Game Programming / getting image from a x y coordinate

i name all my object with object.name. What i do is build a map in 3 part and name each tile with border, ground, object. When my character move on i check if the object clicked is a ground and then move the character to that position. I want to do the same with my npc so i need to check if the x and y coordinate of the next move is a ground and walkable.

 
Flag Post

Topic: Game Programming / getting image from a x y coordinate

Hey guys im making a npc walk into a tilebased map and im choosing randomly coordinate like this:

x = randomize(mindistance,maxdistance);
y = randomize(mindistance,maxdistance);

with mouse event handler i can just do e.target.x and i can get the tile coordinate then align my character to move in middle of it no prob, i just want to reproduce this with my npcs. I dont know how to find the object any ideas?

 
Flag Post

Topic: Game Programming / Have problem coding?

http://www.youtube.com/watch?v=1S1fISh-pag

 
Flag Post

Topic: Game Programming / as3: quick answer

you dont see the trace made a hero ?

 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

i dont think the i—; is necessary too since the loop is in a enter frame it will check again and again anyway… thats could be an issue when there is more object to check tought… Thats why i was wondering first if it was a good idea to place that loop in a enter frame. But i dont see where else i could place this since i need to check the hittest each time the character move

 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

The array GoldCoinArray contain another array with the bitmap of the coin and the value of that coin only. Using GoldCoinArray.splice(i,1) i remove the entire line of that array since i dont need it anymore right ? I added 10 coin on the map randomly and walked over it thats what is the result of the array after each coin collected, the line was removed perfectly:

Gold collected!
[object Bitmap],2,[object Bitmap],1,[object Bitmap],2,[object Bitmap],2,[object Bitmap],3,[object Bitmap],1,[object Bitmap],3,[object Bitmap],3,[object Bitmap],1
Gold collected!
[object Bitmap],1,[object Bitmap],2,[object Bitmap],2,[object Bitmap],3,[object Bitmap],1,[object Bitmap],3,[object Bitmap],3,[object Bitmap],1
Gold collected!
[object Bitmap],1,[object Bitmap],2,[object Bitmap],2,[object Bitmap],1,[object Bitmap],3,[object Bitmap],3,[object Bitmap],1
Gold collected!
[object Bitmap],1,[object Bitmap],2,[object Bitmap],2,[object Bitmap],1,[object Bitmap],3,[object Bitmap],1

 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

now working fine only changing the 0 to 1… gnah

for (var i = 0; i < GoldCoinArray.length; i++) {
				if (Player.hitTestObject(GoldCoinArray[i][0])) {
					var goldtext:TextStuff = new TextStuff(Player.x, Player.y -(Player.height + 20),GoldCoinArray[i][1],0xFFFF00, 14, false, true,2,1);
					addChild(goldtext);
   					removeChild(GoldCoinArray[i][0]);
					GoldCoinArray.splice(i,1);
					trace("Gold collected!");
				}
			}
 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

and yeah i was doing splice(i,0)… thinking it would target the first cell of my array line, got confused there thats why it was firing many time i guess

 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

Why is that a hack ? I’m not totally sure why that command work actually, i checked google and saw people saying to do this on stackoverflow. I never use the parent function but im guessing it just check if its currently active or not in the parent displayobjectcontainer which should be the stage ?

 
Flag Post

Topic: Game Programming / removeChild on enter_frame event

Solved by myself… Had to speak about it to solve it lol… After a couple hour staring at screen here was the solution:

if (Player.hitTestObject(GoldCoinArray[i][0]) && GoldCoinArray[i][0].parent) {

just added that && GoldCoinArray[i]0.parent and everything goes fine