So to teach myself C# I deciding to make a goofy game. It is called Ascii Fun.
Be warned it is not done by a long shot. Just the start. Kinda ugly and stupid right now
http://www.mediafire.com/?32yzq9cjfdf7ziz
My goofy C# project
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: My goofy C# project
no one tried it
-
- Posts: 261
- Joined: Wed Apr 28, 2010 8:35 am
Re: My goofy C# project
I can't open it at work. I'll try it when I get home.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: My goofy C# project
4 people actually downloaded it...must have been that horrifically bad that it literally caught their hair on fire and froze their minds. The sudden elemental explosion on their head created a mini black hole and sucked them in...
eh wouldn't be the first time.
I updated it. Added notebook paper to play on. Building maps now.
eh wouldn't be the first time.
I updated it. Added notebook paper to play on. Building maps now.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: My goofy C# project
Nice! I tried it out, and it worked fine. Anyone having issues likely doesn't have a high enough version of .NET runtime to play it (it is unlikely today that someone doesn't have a version of .NET at all).
One thing you can do to improve the keyboard response is to get around the keyboard buffer. The reason the symbol moves once as soon as you hit the key, but then waits a moment, and then moves again if you hold it down, but only in a cardinal direction is due to the Window's keyboard buffer, which is there to simplify typing. You would get around it by using velocities. Here is some ActionScript that shows how to do this:
Although AS is a bit differently syntaxed than C#, they are quite similar. The important things to note is that in the KEY_DOWN event, I am not moving the character. I am only setting a fixed value (however much each key press or hold should move the character, usually around 5 - 20) to a vx, which would be negative if left and positive for right, and vy variable, which is negative for up and positive for down. Then in the KEY_UP event, I am setting those 2 variables back to 0 so they will not continue to make the character move. Then in the ENTER_FRAME event (which in C# would be whatever loop-like event or structure where you are actually moving the character graphic), you add those vx and vy variables to the x and y values of the character, respectively.
You may already know all of this, in which case it is just information for others, but even though it doesn't seem like much of a change, it gets around the terrible (for games) buffer. You will now move smoothly and can move diagonally.
One thing you can do to improve the keyboard response is to get around the keyboard buffer. The reason the symbol moves once as soon as you hit the key, but then waits a moment, and then moves again if you hold it down, but only in a cardinal direction is due to the Window's keyboard buffer, which is there to simplify typing. You would get around it by using velocities. Here is some ActionScript that shows how to do this:
Code: Select all
package {
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
public class moveCharacter_main extends MovieClip {
private var vx:int;
private var vy:int;
private var myChar:Character;
public function moveCharacter_main() {
init();
myChar = new Character();
myChar.x = 50;
myChar.y = 50;
vy = 0;
vx = 0;
stage.addChild(myChar);
}
private function init():void {
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownF);
stage.addEventListener(Event.ENTER_FRAME, onFrameEnterF);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpF);
}
private function onKeyDownF(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.UP) {
vy = -5;
} else if (event.keyCode == Keyboard.DOWN) {
vy = 5;
} else if (event.keyCode == Keyboard.LEFT) {
vx = -5;
} else if (event.keyCode == Keyboard.RIGHT) {
vx = 5;
}
}
private function onFrameEnterF(event:Event):void {
myChar.x += vx;
myChar.y += vy;
}
private function onKeyUpF(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.UP) {
vy = 0;
} else if (event.keyCode == Keyboard.DOWN) {
vy = 0;
} else if (event.keyCode == Keyboard.LEFT) {
vx = 0;
} else if (event.keyCode == Keyboard.RIGHT) {
vx = 0;
}
}
}
}
You may already know all of this, in which case it is just information for others, but even though it doesn't seem like much of a change, it gets around the terrible (for games) buffer. You will now move smoothly and can move diagonally.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: My goofy C# project
very kewl! Thanks for the info.
Re: My goofy C# project
I know this is an old topic but I had a question. How did you get the background of the A to be transparent lol? My images have like a white square or w/e the background of it is. thanks