Posted by: spawnfestis on: March 24, 2009
Hi,
Since I’ve started doing PHP. I have a test-site rigged up here where you can find my examples in a running environment.
To sponsor me, click the Advertisement at the top of the pages once every day. Highly appreciated
Bye for now!
spawnfestis
Posted by: spawnfestis on: March 24, 2009
default.php
Create a form with the name “guessedNum”, it should be an input form, and it should refer to guessgame.php
guessgame.php
<?php
// Declarations
$randNum = mt_rand(1,5);// $_POST['nameofpostedarea'] returns what you sent from the default.php file,
// thus how you can use it to build a simple game
echo “You guessed “.$_POST['guessedNum'].”.“;
if ($_POST['guessedNum'] == $randNum) {
echo “And you won! The right number was indeed “.$_POST['guessedNum'].” !“;
}
else if($_POST['guessedNum'] > 5 || $_POST['guessedNum'] < 0) { // If the user tries to break the rules
echo “Omg. I said between 1-5 which means “.$_POST['guessedNum'].” is invalid..“;
} else {
echo “But you lost.. because the right number was “.$randNum.”“;
}
?>
Posted by: spawnfestis on: March 24, 2009
Commented codesnippet for practicing PHP as a beginner.
Includes while-looping and variable declaring.
This helped me to understand PHP-syntax at it’s most basic level, but hey, got to start somewhere
<?php // PHP start tag.
// Declaration in PHP
$i = 0; // Just a variable, you don’t need to assign a data type in PHP!while($i < 5){ // Easy while loop, works like with C# or any other larger programming language
echo “Yahoo!
“; // Just like printf() or std::cout
$i++;
}?>; // End tag, stop the PHP script!
Posted by: spawnfestis on: March 24, 2009
Hi again! So I’ve been away for awhile again, but I’ve started to do a bit of web development during my now three weeks off school.
So here goes a new category: PHP! ![]()
I’ll start putting out samples of scripts, and maybe even create a smaller game available to play in the near future. That’s what I’m aiming for anyhow.
Posted by: spawnfestis on: March 19, 2009
Pretty awesome lesson today!
Fun fact is that if I wanted, I could now make collisions and drop a ball in there and I would have my own little 3D world simulator.
Actually, I’m not too sure I’m going to continue working on this because I’m hopping over to importing .FBX models now as I know how to animate in Maya 3D it’d be convenient to know how to import the models from it too
However, the 3D world is designed out of a “heightmap” which is a light-on-black colored .bmp image, which tells the 3D Engine (which is a very basic one for now ;-P) how huge the ‘spikes‘ should turn out to be. This makes the Engine super-flexible and it would take no more than a minute to draw a new level.
You could compare this to the 3D Maya “bumpmap” to get the concept.
More will be coming up, sorry for not updating the blog so much the past two weeks. I’m going to try better from now on, not to mention that I also have 3 weeks off starting tomorrow!
Special thanks to Riemer.net for his awesome 3D tutorials!
Posted by: spawnfestis on: March 5, 2009
Here you go, two of my classes in two distinct snippets!
GameObject.cs
/*
Author: Jimmy (spawnfestis.wordpress.com)
Revision: 1.0
Description: Essentially gives an object properties to be used within the game constructor
To-do: Add more references and vectors
Known bugs: N/A
*/using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;namespace Breakout
{
class GameObject
{
public Texture2D sprite;
public Vector2 position;
public float rotation;
public Vector2 center;
public Rectangle hitArea;public GameObject(Texture2D loadedTexture)
{
sprite = loadedTexture;
rotation = 0.0f;
position = new Vector2(0, 0);
center = new Vector2(sprite.Width / 2, sprite.Height / 2);
}
}
}
MoveableObject.cs (inherits GameObject.cs or your own GameObject class!)
/*
Author: Jimmy (spawnfestis.wordpress.com)
Revision: 1.0 FINAL
Description: Gives the inheriting class velocity properties
To-do: N/A
Known bugs: Might be a problem with adding yVel at some point,
however – this bug has appeared only once and should be fixed.
*/using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;namespace Breakout
{
class MoveableObject : GameObject
{
public float xVel;
public float yVel;public MoveableObject(Texture2D loadedTexture, float _xVel, float _yVel): base(loadedTexture)
{
xVel = _xVel;
yVel = _yVel;
}public void updatePosition()
{
position.X += xVel;
position.Y -= yVel;
}
}
}
Posted by: spawnfestis on: March 4, 2009
Actually, this week has been rough.
Not only have I set this site up, written the tutorials, refined them from BBCode to what wordpress may like as a markup language, but I’ve also been extremely busy with school.
So, what am I doing in school that is taking up so much of my time? Well, honestly, the usual. Plus the actual game development!
I was assigned to make a breakout-like game, and this is how it has turned out to look like for now:
I’ll post when I’m finished with it, I’ll probably give my project out as open-source as well, as I see no significant value in it.
On the other hand, I’m thinking of starting a real project, something I’ll work with a few other guys in my class and actually finish. That would be awesome!
Bye for today.
Posted by: spawnfestis on: March 4, 2009
Quote by Wikipedia.com:
An assembly language is a low-level language for programming computers. It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on abbreviations (called mnemonics) that help the programmer remember individual instructions, registers, etc. An assembly language is thus specific to a certain physical or virtual computer architecture (as opposed to most high-level languages, which are portable).
Okay, so now you know what Assembly is, no need to question that, right?
Let us begin with what ASM really is, and how you can use it.
Opcodes, what are they?
I’m not going to bring up every single opcode, but this is basically the most important ones. (at least in hacking)
MOV = Move
Move something from one point to another, it’s self-explainable but let me show you.
mov brain, [cells]
This will move “cells” to the “brain”, it’s a humortastical example, but you get it.
CMP = Compare
Simple as it is, it compares the affected stuff.
(compares two registers or a register + a value)
cmp [address], 20
Would compare the address with the value.
JMP = Jump (conditional)
This is a very simple instruction actually, easy as this:
Jmp 00400000
This would make the it jump to the address 0×00400000(0x is an indicator that it is HEX and not DECIMAL, however it is not necessary to write out in ASM.)
As the following is pretty much the same type of memory altering as above, we will just take up what they mean and you will be able to figure it out without any examples really, you’ll see why after reading them.
* JE(JZ) = Jump to if equal
The reason why JZ is there, is because it does the same thing as JE but with ONE exception, and that is – it will only jump if the Zero Flag is applicated at the destination.
* JNE = Jump to if not equal
JG = Jump to if greater than
JL = Jump to if less than
JNG = Jump to if not greater than
JNL = Jump to if not less than
JGE = Jump to if greater than or equal to
JLE = Jump to if less than or equal to
Okay, so now you know all the basic jumps, off to some other..
INC = Increment
Let’s think (hypothetically of course) that the value at EAX is equal to 1.
And now we “INC” that, it would be something like this.
INC eax
The value stored at EAX is now increased to 2.
A little more advanced example:
inc dword ptr [00400000]
This would mean that the value at 00400000 will be increased by 1.
DEC = Decrement
Same as above, but the other way.
EAX = 1
DEC eax
EAX = 0
A little more advanced example:
dec dword ptr [00400000]
This would mean that the value at 004000 will be decreased by 1.
PUSH = pushes a value, point in memory, or register onto the stack.
(Push puts a value ON THE TOP OF THE STACK AND INCREASES THE SIZE OF THE STACK BY 1)
PUSH eax
The syntax for this would be PUSH then either value/register or any memory reference.
More about stacks at wikipedia, click here.
POP = pops a value off the stack into a point in memory or register.
This is the opposite of PUSH (by this I mean that it takes from the stack instead of adding up), and it is usually likely to work with PUSH, since often if a registry is preserved with PUSH EBX you can find POP EBX later in the memory.
Example of the POP syntax:
POP eax
(Remember: Pop takes the value ON THE TOP OF THE STACK.)
See here that the syntax of POP is the same as PUSH?
Good!
I’ve decided to not bring these things up more than this, as it would probably not profit you anyways, but we will bring up what they are.
ALLOC = Reserves space for you to use in the memory
Registersymbol = Makes a symbol you can use for reading / editing values by adding it as a address in your cheat table.
Dealloc = Releases space you reserved.
Unregistersymbol = Reversed of Registersymbol.
Label – Hmm, this is just a label
(Abovementioned is things you will approach in AUTO-ASSEMBLY.)
If you would like to look further into Jumps, I would recommend googling up the following jumps, some which are described above, but anyways.
JMP, JE, JZ, JNE, JNZ, JA, JG, JNA, JNG, JB, JL, JNB, JNL, JAE, JGE, JNAE, JNGE
And incase you didn’t know [] acts like a pointer. Here is a example assuming eax is 0×00400000.
[eax] is saying whatever is stored at 0×400000
Hope you got something out of reading this!
Posted by: spawnfestis on: March 4, 2009
For any game you will need a game loop, but what is a game loop really?
It’s pretty easy, a game loop consists of one code block that continuously is looped through to constantly run code you want to run realtime.
Lets start off with a fresh project -
package {
import flash.display.MovieClip;public class Main extends MovieClip {
//Global variables
public function Main() {}
}
}
The game loop idea needs one of the package imports called Event, since you’re adding a eventListener.
package {
import flash.display.MovieClip;
import flash.events.Event;public class Main extends MovieClip {
//Global variables
public function Main() {
stage.addEventListener(Event.ENTER_FRAME, updateGame);
}
}
}
I’ve also added in the addEventListener() code there, so that you can see how it is used in a real situation.
Event.ENTER_FRAME symbolises that it’ll be running all the time, and updateGame is a function name, a function which we need to create for the eventListener to work properly without dragging out errors.
So we add the function to our code, like this -
package {
import flash.display.MovieClip;
import flash.events.Event;public class Main extends MovieClip {
//Global variables
public function Main() {
stage.addEventListener(Event.ENTER_FRAME, updateGame);
}private function updateGame():void {
trace(“hi”);
}
}
}
Now the eventListener will call for your updateGame() function on every new frame (depending on your frames per seconds setting, it’ll go faster/slower to call the updateGame() function).
Run your code and you’ll get it!
Hope you learned something
bye