Sign in to follow this  
capn_midnight

3H-GDC m.V: Something Special (winner: BeanDog)

Recommended Posts

scgrn    168
Quote:
Original post by d000hg
...
scgrn:Didn't you enter last time?

I entered the last 1W1B contest, but I've never done the 3H-GDC. It sounds like a blast... I'm really looking forward to it.

Share this post


Link to post
Share on other sites
d000hg    1199
Quote:
Original post by scgrn
Quote:
Original post by d000hg
...
scgrn:Didn't you enter last time?

I entered the last 1W1B contest, but I've never done the 3H-GDC. It sounds like a blast... I'm really looking forward to it.
Yeah it IS fun. I found it to be almost exactly like an exam with an essay question:
  • Spend a while planning what you're going to do.

  • Panic when you realise 1/2 an hour has gone and you've not started yet.[/li]
  • Frantically start coding.

  • Frantically create some horrible 'artwork' in Paint.

  • Start to get into it as a compilable application which renders something is reached.

  • Panic some more as you realise only 30min is left and you still have just a framework on which to build a game.

  • Throw together some basic gameplay, leaving out the majority of what you wasted the first 30min planning.

  • Frantically zip and email the entry when you remember that the deadline is when it should be sent, not when you should stop coding.

  • Collapse/get beer/watch on the forums and enjoy the others who are still desperately trying to figure out how to submit their entry.


  • So a lot like an exam really - a middle period of actually getting on with it surrounded by panic at either end. I think I'll copy and paste this as my post-mortem for the contest THIS time, actually.

    Share this post


    Link to post
    Share on other sites
    d000hg    1199
    That is a good question. What about freely available resources from the web, as well? Realistically few of us could add sound if we had to make it ourselves at all, let alone in 3 hours! And adding sound to a 3H contest entry would be a rare bit of polish indeed.

    By the way...


    This is my D3D console mode emulator. Firstly, capn_midnight is there anything to make you think this would not be allowed? Secondly, is anyone keen on using it? There's a couple of utility functions I might add but it currently has the ability to set a character, write a string, and draw a dithered block between 2 colours.

    [Edited by - d000hg on February 8, 2006 8:51:56 AM]

    Share this post


    Link to post
    Share on other sites
    paulecoyote    1065
    Quote:
    Original post by capn_midnight
    public domain sound and music is fine.

    your D3D emulator looks fine.


    By that you mean music that either is freely distributable or you have the permission / the distribution rights too?

    Cos I have a friend who composes stuff and he might be up for me using his own original material.

    Share this post


    Link to post
    Share on other sites
    paulecoyote    1065
    another question - anyone know of any good .Net 2 console input examples suitable for controlling a game?

    Trying to get my head around DllImporting GetKeyState and GetKeyboardState and don't seem to be getting very far.

    It's odd cos I could do this keyboard control in C++ no troubles, but I kind of want to do this in C# 2 [smile]

    Share this post


    Link to post
    Share on other sites
    Thevenin    270
    Well, I spent an hour and made a neat intro with MDX playing a few MIDIs in C#.

    The performance isn't too great though (About 10 FPS). And I haven't a C# way to get keyboard input.

    My Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Media;
    using System.Drawing;
    using System.Windows.Forms;
    using Microsoft.DirectX;
    using Microsoft.DirectX.AudioVideoPlayback;

    public partial class cMain
    {
    public class ASprite
    {
    public Color MyTransparentConst = Color.FromArgb(255, 0, 255);
    public int TheWidth;
    public int TheHeight;
    public Color[] TheColors;

    public ASprite(int TheWidth, int TheHeight)
    {
    this.TheWidth = TheWidth;
    this.TheHeight = TheHeight;

    TheColors = new Color[this.TheWidth * this.TheHeight];
    for (int TheLoop = 0; TheLoop < this.TheWidth * this.TheHeight; TheLoop++)
    TheColors[TheLoop] = new Color();
    }
    public ASprite(string TheFileName)
    {
    Bitmap TheBitmap = new Bitmap(TheFileName);
    this.TheWidth = TheBitmap.Width;
    this.TheHeight = TheBitmap.Height;

    TheColors = new Color[this.TheWidth * this.TheHeight];
    for (int TheLoop = 0; TheLoop < this.TheWidth * this.TheHeight; TheLoop++)
    TheColors[TheLoop] = new Color();

    for (int TheX = 0; TheX < this.TheWidth; TheX++)
    for (int TheY = 0; TheY < this.TheHeight; TheY++)
    TheColors[TheX + TheY * this.TheWidth] = TheBitmap.GetPixel(TheX, TheY);
    }

    public void sDraw(int TheSrcX, int TheSrcY, int TheSrcWidth, int TheSrcHeight,
    int TheDestX, int TheDestY, Color[] TheDestination)
    {
    for (int TheX = 0; TheX < TheSrcWidth; TheX++)
    for (int TheY = 0; TheY < TheSrcHeight; TheY++)
    /* Lets just make sure we are within bounds. */
    if (TheX >= 0 && TheX < 80 &&
    TheY >= 0 && TheY < 50)
    /* And lets make sure its not a transparency color. */
    if(this.TheColors[TheSrcX+TheX + (TheSrcY+TheY)*TheWidth] != MyTransparentConst)
    TheDestination[TheX + TheDestX + (TheY + TheDestY) * 80] =
    this.TheColors[TheSrcX + TheX + (TheSrcY + TheY) * TheWidth];
    }
    }


    /* Load the music files needed. */
    public Audio MyIntroMusic = new Audio("Resources\\Intro.mid");

    /* Load the sources needed. */
    public ASprite MyLogo = new ASprite("Resources\\Logo.png");

    /* Game variables. */
    public enum EGameState
    {
    Menu,
    InGame,
    Quit
    }
    public EGameState MyGameState = EGameState.Menu;

    /* My render framebuffer. */
    public Color[] MyRender = null;
    public Color[] MyPreviousRender = null;

    /* Various Animations. */
    public int TheLogoAnimation = 0;

    /* No touch. */
    static void Main(string[] args)
    {
    cMain TheGame = new cMain();
    TheGame.sLoad();
    }

    /* Load procedure; also main game loop. */
    public void sLoad()
    {
    /* Configure the console window. */
    Console.WindowWidth = 80;
    Console.WindowHeight = 50;
    Console.Title = "GameDev.Net 3H-GDC (Thevenin Entry)";

    /* Build my renderer. */
    MyRender = new Color[80*50];
    for(int TheLoop=0; TheLoop<80*50; TheLoop++)
    MyRender[TheLoop] = new Color();
    MyPreviousRender = new Color[80 * 50];
    for (int TheLoop = 0; TheLoop < 80 * 50; TheLoop++)
    MyPreviousRender[TheLoop] = new Color();

    /* Get the ticks. */
    int TheCurrentTickCount = Environment.TickCount;
    int TheLastTickCount = TheCurrentTickCount;

    /* Start the music. */
    MyIntroMusic.Play();


    /* Game loop. */
    while(MyGameState == EGameState.InGame ||
    MyGameState == EGameState.Menu)
    {
    TheCurrentTickCount = Environment.TickCount;
    if(TheCurrentTickCount - TheLastTickCount >= 100)
    {
    /* Get the graphics thingy ready. */
    sPrepareRender();

    TheLastTickCount = TheCurrentTickCount;
    }
    }

    /* Finish. */
    MessageBox.Show("Thank you for playing~");
    }

    /* Prepare the Render. */
    public void sPrepareRender()
    {

    TheLogoAnimation++;
    if (TheLogoAnimation == 10)
    {
    MyLogo.sDraw(0, 0, 80, 50, 0, 0, MyRender);
    sRender();
    }
    else if (TheLogoAnimation == 20)
    {
    MyLogo.sDraw(0, 50, 80, 50, 0, 0, MyRender);
    sRender();
    TheLogoAnimation = 0;
    }
    }


    /* Render a frame. */
    public void sRender()
    {
    for (int TheY = 0; TheY < 50; TheY++)
    for(int TheX = 0; TheX < 80; TheX++)
    if(TheY != 49 || TheX != 79)
    if(MyRender[TheX+TheY*80] != MyPreviousRender[TheX+TheY*80])
    {
    Color TheColor = MyRender[TheX + TheY*80];
    if (TheColor == Color.FromArgb(0,0,255))
    Console.BackgroundColor = ConsoleColor.Blue;
    else if (TheColor == Color.FromArgb(0, 0, 128))
    Console.BackgroundColor = ConsoleColor.DarkBlue;
    else if (TheColor == Color.FromArgb(0, 0, 0))
    Console.BackgroundColor = ConsoleColor.Black;
    else if (TheColor == Color.FromArgb(255, 255, 255))
    Console.BackgroundColor = ConsoleColor.White;
    else if (TheColor == Color.FromArgb(0, 255, 0))
    Console.BackgroundColor = ConsoleColor.Green;
    else if (TheColor == Color.FromArgb(0, 128, 0))
    Console.BackgroundColor = ConsoleColor.DarkGreen;

    Console.SetCursorPosition(TheX, TheY);
    Console.Write(" ");
    // added in as an optimization instead of putting it below in the commeneted out region.
    MyPreviousRender[TheX + TheY * 80] = MyRender[TheX + TheY * 80];
    }

    /* Lastly, we'll want to copy the new render onto the old one. */
    //for (int TheY = 0; TheY < 50; TheY++)
    // for (int TheX = 0; TheX < 80; TheX++)
    // MyPreviousRender[TheX + TheY * 80] = MyRender[TheX + TheY * 80];
    }
    }



    I might just use WindowsForms, since I don't want to attempt this in 3 hours in Procedural-C...

    [Edited by - Thevenin on February 8, 2006 9:45:49 PM]

    Share this post


    Link to post
    Share on other sites
    d000hg    1199

    d000hg's D3D Console Emulator v1.0


    I thought I'd make all the base code I plan to use available to you all, in case anyone thought of entering but couldn't be arsed to find out how to do text-mode coding.
    It uses D3D8.1 and supports the following:
  • Set character, with foreground & background colour.

  • Set character without changing colours at that location

  • Set colours without changing the character at that location

  • Draw dithered blocks

  • Draw dithered rectangles

  • Draw a frame/border, or a dual-panel frame (see screenshot)

  • Draw a string, which wraps around if required


  • You can get it here:
    http://www.sendmefile.com/00274115, including the .dds font file and a VS6 workspace. A sample app is present including D3D initialisation. Check D3DConsoleEmulator.h for a list of special characters like those in the screenshot.
    You may use any of this code for any purpose as long as you let me know and give me a mention somewhere.
    It's not meant to be especially good, it's just thrown together for fun! But suggest improvements or report bugs and I'll address them.
    If I make any fixes or add new stuff before Saturday I'll try to release the updated version.
    I threw in a few comments and it should be fairly self explanatory especially from the sample app but feel free to ask me any questions.

    Share this post


    Link to post
    Share on other sites
    capn_midnight    1707
    Quote:
    Original post by paulecoyote
    another question - anyone know of any good .Net 2 console input examples suitable for controlling a game?

    Trying to get my head around DllImporting GetKeyState and GetKeyboardState and don't seem to be getting very far.

    It's odd cos I could do this keyboard control in C++ no troubles, but I kind of want to do this in C# 2 [smile]


    Here is the .NET 2.0 Class Library Reference
    here is the System.Console class
    bool System.Console.KeyAvailable is a boolean property that returns true if a key is on the input stream
    System.ConsoleKeyInfo System.Console.ReadKey([bool suppresDisplay]) blocks and returns a ConsoleKeyInfo struct when a key is available on the input stream. It also has an optional boolean parameter that setting to true causes the key to not echo to the screen
    System.ConsoleKeyInfo primarily holds flags for the ctrl, shift, and alt key, as well as a value for the System.ConsoleKey that was pressed
    System.ConsoleKey is an enumeration of virtual keys, including definitions for the arrow keys.

    Share this post


    Link to post
    Share on other sites
    paulecoyote    1065
    Quote:
    Original post by capn_midnight
    Quote:
    Original post by paulecoyote
    another question - anyone know of any good .Net 2 console input examples suitable for controlling a game?

    Trying to get my head around DllImporting GetKeyState and GetKeyboardState and don't seem to be getting very far.

    It's odd cos I could do this keyboard control in C++ no troubles, but I kind of want to do this in C# 2 [smile]


    Here is the .NET 2.0 Class Library Reference
    here is the System.Console class
    bool System.Console.KeyAvailable is a boolean property that returns true if a key is on the input stream
    System.ConsoleKeyInfo System.Console.ReadKey([bool suppresDisplay]) blocks and returns a ConsoleKeyInfo struct when a key is available on the input stream. It also has an optional boolean parameter that setting to true causes the key to not echo to the screen
    System.ConsoleKeyInfo primarily holds flags for the ctrl, shift, and alt key, as well as a value for the System.ConsoleKey that was pressed
    System.ConsoleKey is an enumeration of virtual keys, including definitions for the arrow keys.


    Hey thanks for that. I did see some of that stuff but I was looking to figure out keydown and keyup events. In the end I managed to wrap win32 ReadConsoleInput and some over pinvoked functions to do that. I expect I'll post the code with my entry - I want to comment it some more and hammer it before inflicting it on the world. I'm determined to get an entry in for one of these competitions!

    So can I use my friends music with his permission then?

    Share this post


    Link to post
    Share on other sites
    scgrn    168
    Quote:
    Original post by matt_j
    Is 80x50 or 80x43 allowed?

    This question has already been fielded. I believe the answers was "yeeeeup".

    Share this post


    Link to post
    Share on other sites
    Thevenin    270
    Quote:
    Original post by matt_j
    Is 80x50 or 80x43 allowed?


    They are both allowed. Be warned though, as the screensize increases, the framerate descreases.

    Us C# Console coders (Without using the Win32API) have some solid restraints on what we can do due the bad performance....

    Here's a quicky on what I'm working on (it glows! [grin]). Less than 10 FPS though, and the only redraws are done on parts that have changed.

    Share this post


    Link to post
    Share on other sites
    d000hg    1199
    You mean instead of setting a character, set several characters to a solid block to make a larger image of a font? If you have a 2D bool array (say 8x8) for each character then just set which 'bits' are on or off and then use this to draw your character on screen... of course it is a pain to generate those masks. You could get an image of all characters (look at the .dds file in my example) and then write a function to use that, or maybe there is a DOS function to get you the mask for each character.

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this