collapse collapse

* Who's Online

  • Dot Guests: 142
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11164
  • stats Total Topics: 1700
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 1470

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - mager1794

Pages: [1]
1
Beta Releases / Random Number Generator
« on: March 15, 2014, 10:59:47 am »
I created a conceptual Random Number Generator by establishing a table filled with randomly pressed numbers reaching 8 digits. With the highest number being 59999999.

I don't exactly have the time to create a perfect random number generator so its not the most randomness.

At its highest capacity its pretty much a 1/n chance to be picked where n is the size of my number array.

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    public static class NumberGenerator
    {
        //Type out random numbers
        //Max Number 59999999
        //Min Number 0
        static int currentPosition = 0;
        static int[] number = {0, 38491028, 59293982, 19297329, 42738293, 39927290, 59281023, 18326283, 29127492, 5999999, 50192839, 19382739,29372382,19283749 , 49282328, 32817238, 19237482, 59182839,12938292,29385919,39581828};


        public static int Next()
        {
            currentPosition++;
            if (currentPosition >= number.Length)
                currentPosition = 0;

            return number[currentPosition];
        }

        public static int Next(int min,int max)
        {
            return (Next()% (max - (min - 1))) + min;
        }

        public static void Seed()
        {
            Seed(DateTimeToInteger(DateTime.Now));
        }

        public static void Seed(int i)
        {
            currentPosition = (i % number.Length);
        }

        public static int DateTimeToInteger(DateTime time)
        {

            Console.WriteLine(number.Length.ToString());

            string s = "";

            s += time.Year.ToString();
            s += time.Day.ToString();
            s += time.Minute.ToString();


            return int.Parse(s);
        }
    }
}

2
Code Snipplets / Piglatin Converter
« on: March 14, 2014, 10:16:04 am »
Simple algorithm to parse typed in the console and to return an sentence output in the form of piglatin

Follows a standard pattern of finding the first vowel and shifting all the letters before the vowel to the end of the sentence and adding 'ay'

if the first letter is the first vowel, it just adds 'yay' to the word. if there are no common vowels. then the system will check for 'y' as a vowel.


Code: [Select]
static char[] vowels = { 'a', 'e', 'i', 'o', 'u'};
static string ConvertToPigLatin(string message)
        {
            string[] words = message.Split(' ');
            string pigLatin = "";

            foreach(string word in words)
            {

                pigLatin += ConvertWordToPigLatin(word) + " ";
            }

            return pigLatin;

        }

        static string ConvertWordToPigLatin(string word)
        {
            string pigLatin = "";
            string temp_word_b = "";
            string temp_word_e = "";
            int index = 0;
            int found_index = -1;

            foreach (char c in word.ToLower())
            {
               
                if (temp_word_b == "")
                {
                    foreach (char v in vowels)
                    {
                        if (c == v)
                        {
                            found_index = index;
                        }

                    }

                    if (found_index > -1)
                        temp_word_b += c;
                    else
                        temp_word_e += c;
                }
                else
                {
                    temp_word_b += c;
                }

                index++;

            }

            if (found_index > -1)
            {
                string ender = "ay";
                if (found_index == 0)
                    ender = "yay";

                pigLatin = (temp_word_b + temp_word_e + ender);

                return pigLatin;
            }
            else
            {
                return ConvertWordToPigLatin(word, true);
            }
        }

        static string ConvertWordToPigLatin(string word, bool useY)
        {
            if (useY)
            {
                string pigLatin = "";
                string temp_word_b = "";
                string temp_word_e = "";

                char[] vowelset = new char[vowels.Length + 1];
                int i = 0;
                foreach (char v in vowels)
                {
                    vowelset[i] = v;
                    i++;
                }

                vowelset[i] = 'y';


                foreach (char c in word.ToLower())
                {
                    bool vowel_found = false;
                    if (temp_word_b == "")
                    {
                        foreach (char v in vowelset)
                        {
                            if (c == v)
                            {
                                vowel_found = true;
                            }

                        }

                        if (vowel_found)
                            temp_word_b += c;
                        else
                            temp_word_e += c;
                    }
                    else
                    {
                        temp_word_b += c;
                    }

                }

                pigLatin = (temp_word_b + temp_word_e + "ay");

                return pigLatin;
            }
            else
            {
                return ConvertWordToPigLatin(word);
            }
        }
       

3
C# / Project
« on: March 13, 2014, 07:05:05 pm »
I took a break from programming for a while (not my choice) but coming back things just feel strange, like a teenager trying to get a date I feel like I cant find a place to start.  I want to work on something that is kind of large, not quick script solutions. I would like to freshen up on my Object Orientation to complete my project. So I guess my question is...

Can you guys think of any projects that I could do? Preferably something with some problem solving. And Something that's going to require some real architecture to maintain if I were to choose to do so.

Appreciate the help guys, coders block is a bitch.

4
C++ / Undeclared Indentifier
« on: April 30, 2013, 03:09:25 pm »
Im getting an Undeclared identifier when i try to reference my Object class inside of the ObjectManager class.

I cannot seem to pinpoint what im doing wrong here.

5
OpenGL / Irritating Linking Issues
« on: October 25, 2011, 07:31:47 pm »
I have a file with  common functions that i use through out my entire program and for some reason when I'm including it in multiple files it gets linking errors but I was pretty sure I did it right.  Any assistance please

Common.h
Code: [Select]
#ifndef _COMMON_
#define _COMMON_

#include "SDL.h"
#include "SDL_image.h"
#include <string>

struct Vector2
{
int x;
int y;
};


SDL_Surface *load_image( std::string filename )
{
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;

loadedImage = IMG_Load( filename.c_str() );

if( loadedImage != NULL )
{
optimizedImage = SDL_DisplayFormat( loadedImage ); 
SDL_FreeSurface( loadedImage );
}

return optimizedImage;
}

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;

//Give the offsets to the rectangle
offset.x = x;
offset.y = y;

//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
}

#endif

Ball.cpp
Code: [Select]
#include "Ball.h"
#include "Common.h"

void Ball::Draw(SDL_Surface * screen)
{
}

void Ball::Load()
{
ball = load_image("ball.png");
}

void Ball::Unload()
{
}

void Ball::Update()
{
}

Game.cpp
Code: [Select]
#include "Game.h"
#include "Common.h"

bool gameOver = false;

Game::Game()
{
}

void Game::Draw(SDL_Surface *screen)
{
}

void Game::Update()
{

if(iKeyboard.IsKeyDown(SDLK_UP))
gameOver = true;

}

void Game::Load()
{
}

void Game::Unload()
{

}

bool Game::IsOver()
{
return gameOver;
}


void Game::Events()
{
iKeyboard.Clear();
if( SDL_PollEvent( &event ) )
{
if( event.type == SDL_KEYDOWN )
{
iKeyboard.keys[event.key.keysym.sym] = 1;
}


if( event.type == SDL_QUIT )
{
gameOver = true;
}
}
}

Any ideas what Im doing wrong?



6
Code Snipplets / [OpenGL] Custom Triangle Drawing (TriForce)
« on: September 05, 2010, 01:40:59 am »
Some very simple code using glBegin(GL_LINES) to draw triangles.  The position is the center of the triangle and the function does all the calculations just pick a location :P.

There are 3 functions
CreateSmallTriangle - creates a tiny triangle.
CreateLargeTriangle - creates a large triangle.
CreateTriangle - creates a triangle and allows the size to be specified.

As well a custom structure
Vector3 - used to define coordinate sets.

Code: C++
  1. struct Vector3
  2. {
  3.         GLfloat x;
  4.         GLfloat y;
  5.         GLfloat z;
  6.  
  7.         Vector3(GLfloat vx,GLfloat vy,GLfloat vz)
  8.         {
  9.                 x = vx;
  10.                 y = vy;
  11.                 z = vz;
  12.         }
  13. };
  14.  
  15. void CreateSmallTriangle(Vector3 * loc)
  16. {
  17.         glBegin(GL_LINES);
  18.  
  19.                 //First Line
  20.                 glVertex3f(loc->x,loc->y + 0.1f,loc->z);
  21.                 glVertex3f(loc->x - 0.1f,loc->y - 0.1f,loc->z);
  22.  
  23.                 //Second Line
  24.                 glVertex3f(loc->x - 0.1f,loc->y - 0.1f,loc->z);
  25.                 glVertex3f(loc->x + 0.1f,loc->y - 0.1f,loc->z);
  26.                
  27.                 //Third Line
  28.                 glVertex3f(loc->x + 0.1f,loc->y - 0.1f,loc->z);
  29.                 glVertex3f(loc->x,loc->y + 0.1f,loc->z);
  30.  
  31.         glEnd();
  32. }
  33.  
  34. void CreateTriangle(Vector3 * loc,GLfloat size)
  35. {
  36.         glBegin(GL_LINES);
  37.                 //First Line
  38.                 glVertex3f(loc->x,loc->y + size,loc->z);
  39.                 glVertex3f(loc->x - size,loc->y - size,loc->z);
  40.  
  41.                 //Second Line
  42.                 glVertex3f(loc->x - size,loc->y - size,loc->z);
  43.                 glVertex3f(loc->x + size,loc->y - size,loc->z);
  44.                
  45.                 //Third Line
  46.                 glVertex3f(loc->x + size,loc->y - size,loc->z);
  47.                 glVertex3f(loc->x,loc->y + size,loc->z);
  48.  
  49.         glEnd();
  50. }
  51.  
  52. void CreateLargeTriangle(Vector3 * loc)
  53. {
  54.         glBegin(GL_LINES);
  55.  
  56.                 //First Line
  57.                 glVertex3f(loc->x,loc->y + 0.9f,loc->z);
  58.                 glVertex3f(loc->x - 0.9f,loc->y - 0.9f,loc->z);
  59.  
  60.                 //Second Line
  61.                 glVertex3f(loc->x - 0.9f,loc->y - 0.9f,loc->z);
  62.                 glVertex3f(loc->x + 0.9f,loc->y - 0.9f,loc->z);
  63.                
  64.                 //Third Line
  65.                 glVertex3f(loc->x + 0.9f,loc->y - 0.9f,loc->z);
  66.                 glVertex3f(loc->x,loc->y + 0.9f,loc->z);
  67.  
  68.         glEnd();
  69. }
  70.  


Using the code above I created the triforce symbol from the legend of zelda
Code: C++
  1. CreateLargeTriangle(&Vector3(-1.0f,-0.8f,0.0f));
  2. CreateLargeTriangle(&Vector3(0.80f,-0.8f,0.0f));
  3. CreateLargeTriangle(&Vector3(-0.1f,1.0f,0.0f));
  4.  


[edited name=mager1794 date=1283669810][/edited]

7
Beta Releases / Morse Code Translator
« on: August 26, 2010, 05:21:22 pm »
The Code Isn't All Mine!

I found a morse code translator, that simply outputted "Hello World"

I really like the though of morse code, i mean who wouldn't.  There were a few problems with the translator in my opinion so basically what I did was a bunch of edits.  And now its a great translator for any sentence or even paragraph if you so choose.

Code: C++
  1. #include <windows.h>
  2.  
  3.  #include <string>
  4.  
  5.  #include <algorithm>
  6.  #include <iostream>
  7.  
  8.  
  9.  
  10.  typedef std::string::iterator siter;
  11.  
  12.  
  13.  
  14.  using std::string;
  15.  using namespace std;
  16.  
  17.  
  18.  
  19.  void MorseCode(string transmission);  // prototype
  20.  
  21.  void LongBeep() { Beep(700, 500); }
  22.  
  23.  void ShortBeep() { Beep(750, 100); }
  24.  
  25.  
  26.  
  27.  int main()
  28.  {
  29.                         bool cont = true;
  30.          string letters;
  31.          while(cont)
  32.          {
  33.                  cout << "Enter Your Message (/exit will exit):\n";
  34.          getline(std::cin,letters);
  35.          if(letters == "/exit")
  36.                                 cont = false;
  37.              else
  38.              {
  39.                          cout << "\nBegining Morse Code Operations\n";
  40.                          cout << "Outputting Morse code...\n";
  41.          MorseCode(letters);
  42.          cout << "Translation Complete\n\n\n";
  43.                  }
  44.                  system("pause");
  45.                          system("cls");
  46.                  
  47.                  }
  48.          
  49.          return 0;
  50.  
  51.  }
  52.  
  53. //// Not created by me - by some dude on dream in code
  54.  
  55.  void MorseCode(string transmission) {
  56.  
  57.          std::transform(transmission.begin(), transmission.end(), transmission.begin(), ::tolower);
  58.  
  59.  
  60.  
  61.          for(siter x = transmission.begin(); x != transmission.end(); x++) {
  62.  
  63.                  char ch = (*x);
  64.  
  65.                                  cout << "Outputting '";
  66.                                  cout << ch;
  67.                                  cout << "'\n";
  68.  
  69.                  switch(ch) {
  70.  
  71.                          case 'a':
  72.  
  73.                                  ShortBeep();
  74.  
  75.                                  LongBeep();
  76.  
  77.                                  break;
  78.  
  79.                        
  80.  
  81.                          case 'b':
  82.  
  83.                                  LongBeep();
  84.  
  85.                                  ShortBeep();
  86.  
  87.                                  ShortBeep();
  88.  
  89.                                  ShortBeep();
  90.  
  91.                                  break;
  92.  
  93.                        
  94.  
  95.                          case 'c':
  96.  
  97.                                  LongBeep();
  98.  
  99.                                  ShortBeep();
  100.  
  101.                                  LongBeep();
  102.  
  103.                                  ShortBeep();
  104.  
  105.                                  break;
  106.  
  107.  
  108.  
  109.                          case 'd':
  110.  
  111.                                  LongBeep();
  112.  
  113.                                  ShortBeep();
  114.  
  115.                                  ShortBeep();
  116.  
  117.                                  break;
  118.  
  119.  
  120.  
  121.                          case 'e':
  122.  
  123.                                  ShortBeep();
  124.  
  125.                                  break;
  126.  
  127.  
  128.  
  129.                          case 'f':
  130.  
  131.                                  ShortBeep();
  132.  
  133.                                  ShortBeep();
  134.  
  135.                                  LongBeep();
  136.  
  137.                                  ShortBeep();
  138.  
  139.                                  break;
  140.  
  141.                        
  142.  
  143.                          case 'g':
  144.  
  145.                                  LongBeep();
  146.  
  147.                                  LongBeep();
  148.  
  149.                                  ShortBeep();
  150.  
  151.                                  break;
  152.  
  153.  
  154.  
  155.                          case 'h':
  156.  
  157.                                  ShortBeep();
  158.  
  159.                                  ShortBeep();
  160.  
  161.                                  ShortBeep();
  162.  
  163.                                  ShortBeep();
  164.  
  165.                                  break;
  166.  
  167.  
  168.  
  169.                          case 'i':
  170.  
  171.                                  ShortBeep();
  172.  
  173.                                  ShortBeep();
  174.  
  175.                                  break;
  176.  
  177.  
  178.  
  179.                          case 'j':
  180.  
  181.                                  ShortBeep();
  182.  
  183.                                  LongBeep();
  184.  
  185.                                  LongBeep();
  186.  
  187.                                  LongBeep();
  188.  
  189.                                  break;
  190.  
  191.                        
  192.  
  193.                          case 'k':
  194.  
  195.                                  LongBeep();
  196.  
  197.                                  ShortBeep();
  198.  
  199.                                  LongBeep();
  200.  
  201.                                  break;
  202.  
  203.  
  204.  
  205.                          case 'l':
  206.  
  207.                                  ShortBeep();
  208.  
  209.                                  LongBeep();
  210.  
  211.                                  ShortBeep();
  212.  
  213.                                  ShortBeep();
  214.  
  215.                                  break;
  216.  
  217.  
  218.  
  219.                          case 'm':
  220.  
  221.                                  LongBeep();
  222.  
  223.                                  LongBeep();
  224.  
  225.                                  break;
  226.  
  227.                          case 'n':
  228.  
  229.                                  LongBeep();
  230.  
  231.                                  ShortBeep();
  232.  
  233.                                  break;
  234.  
  235.                        
  236.  
  237.                          case 'o':
  238.  
  239.                                  LongBeep();
  240.  
  241.                                  LongBeep();
  242.  
  243.                                  LongBeep();
  244.  
  245.                                  break;
  246.  
  247.  
  248.  
  249.                          case 'p':
  250.  
  251.                                  ShortBeep();
  252.  
  253.                                  LongBeep();
  254.  
  255.                                  LongBeep();
  256.  
  257.                                  ShortBeep();
  258.  
  259.                                  break;
  260.  
  261.  
  262.  
  263.                          case 'q':
  264.  
  265.                                  LongBeep();
  266.  
  267.                                  LongBeep();
  268.  
  269.                                  ShortBeep();
  270.  
  271.                                  LongBeep();
  272.  
  273.                                  break;
  274.  
  275.  
  276.  
  277.                          case 'r':
  278.  
  279.                                  ShortBeep();
  280.  
  281.                                  LongBeep();
  282.  
  283.                                  ShortBeep();
  284.  
  285.                                  break;
  286.  
  287.  
  288.  
  289.                          case 's':
  290.  
  291.                                  ShortBeep();
  292.  
  293.                                  ShortBeep();
  294.  
  295.                                  ShortBeep();
  296.  
  297.                                  break;
  298.  
  299.  
  300.  
  301.                          case 't':
  302.  
  303.                                  LongBeep();
  304.  
  305.                                  break;
  306.  
  307.  
  308.  
  309.                          case 'u':
  310.  
  311.                                  ShortBeep();
  312.  
  313.                                  ShortBeep();
  314.  
  315.                                  LongBeep();
  316.  
  317.                                  break;
  318.  
  319.  
  320.  
  321.                          case 'v':
  322.  
  323.                                  ShortBeep();
  324.  
  325.                                  ShortBeep();
  326.  
  327.                                  ShortBeep();
  328.  
  329.                                  LongBeep();
  330.  
  331.                                  break;
  332.  
  333.  
  334.  
  335.                          case 'w':
  336.  
  337.                                  ShortBeep();
  338.  
  339.                                  LongBeep();
  340.  
  341.                                  LongBeep();
  342.  
  343.                                  break;
  344.  
  345.  
  346.  
  347.                          case 'x':
  348.  
  349.                                  LongBeep();
  350.  
  351.                                  ShortBeep();
  352.  
  353.                                  ShortBeep();
  354.  
  355.                                  LongBeep();
  356.  
  357.                                  break;
  358.  
  359.                          case 'y':
  360.  
  361.                                  LongBeep();
  362.  
  363.                                  ShortBeep();
  364.  
  365.                                  LongBeep();
  366.  
  367.                                  LongBeep();
  368.  
  369.                                  break;
  370.                                  
  371.                          case ' ':
  372.                                                           Sleep(300);
  373.                                                           break;
  374.  
  375.  
  376.  
  377.                          case 'z':
  378.  
  379.                                  LongBeep();
  380.  
  381.                                  LongBeep();
  382.  
  383.                                  ShortBeep();
  384.  
  385.                                  ShortBeep();
  386.  
  387.                                  break;
  388.  
  389.                          default:
  390.  
  391.                                  break;
  392.  
  393.                  }
  394.  
  395.                  Sleep(50);
  396.  
  397.          }
  398.  
  399.       }
  400.  
  401.  

8
C++ / IrrLicht Engine - Throwing Errors While Attempting OOP
« on: July 28, 2010, 05:49:55 pm »
Theres are 8 files so here they go

main.cpp
Code: [Select]
#include "stdafx.h"
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

// Main Irrlicht Namespace
using namespace irr;

// Sub Namespaces
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

CEngine engine;
int main()
{

printf("Initalized");

engine.Init(L"Hello, World");

engine.Load();

printf("\nRunning Loop");
while(engine.device->run())
{
engine.Update();

engine.Draw();
}

engine.Unload();
}

Heres the heade files - I believe the errors are in here

stdafx.h
Code: [Select]
#include <irr/irrlicht.h>
#include <iostream>
#include "3DModel.h"
#include "Player.h"
#include "CEngine.h"

CEngine.h
Code: [Select]
///////////////////////////////
// ///
// Custom Engine     ///
//   Written By Mager    ///
//////////////////////////////
#pragma once
#include "stdafx.h"

// Main Irrlicht Namespace
using namespace irr;

// Sub Namespaces
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


class CEngine
{
private:
bool activated;
ICameraSceneNode * camera;
public:

Player Plr;
IVideoDriver * driver;
ISceneManager * smgr;
IrrlichtDevice * device;
ICameraSceneNode * GetCamera();
void Init(const wchar_t * text);
void Load();
void Draw();
void Update();
void Unload();
void AddLight(vector3df loc);
};

Player.h
Code: [Select]
#pragma once

#include "stdafx.h"

using namespace irr;

// Sub Namespaces
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

class Player : public Model3D
{
public:
void SetPosition(vector3df newpos);
void UpdateVariables(ICameraSceneNode * cam);
};

3DModel.h
Code: [Select]
#pragma once
///////////////////////////////
// ///
//    3D Model Class ///
//   Written By Mager    ///
//////////////////////////////
#include "stdafx.h"

using namespace irr;

// Sub Namespaces
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

class Model3D
{
private:
IAnimatedMesh * mesh;
IAnimatedMeshSceneNode * node;
public:
vector3df Position;
IAnimatedMeshSceneNode * GetMeshNode();
void Load(const irr::io::path &file,ISceneManager * smgr,IVideoDriver * driver);
void SetTexture(const irr::io::path &file,IVideoDriver * driver);
void Unload();
};

3DModel.cpp
Code: [Select]
#include "3Dmodel.h"

void Model3D::Load(const irr::io::path &file,ISceneManager * smgr,IVideoDriver * driver)
{
mesh = smgr->getMesh(file);
node = smgr->addAnimatedMeshSceneNode(mesh);
Position = vector3df(0,0,0);
if(node)
{
node->setPosition(Position);
}
}

void Model3D::SetTexture(const irr::io::path &file,IVideoDriver * driver)
{
if(node)
{
node->setMaterialFlag(EMF_LIGHTING,false);
node->setMaterialTexture(0,driver->getTexture(file));
}
}

IAnimatedMeshSceneNode * Model3D::GetMeshNode()
{
return node;
}

void Model3D::Unload()
{
mesh->drop();
node->drop();
}

Player.cpp
Code: [Select]
///////////////////////////////
// ///
//    Player Class ///
//   Written By Mager    ///
//////////////////////////////
#include "Player.h"

int curmoment = 0;
bool forward = true;
bool firstround = true;
bool raeshelishere = true;

void Player::UpdateVariables(ICameraSceneNode * cam)
{
vector3df velocity = vector3df(0,0,0.01f);
if(!raeshelishere)
{

if(curmoment == 1500 && firstround)
{
curmoment = 0;
forward = !forward;
firstround = false;
}
else if(curmoment == 3000)
{
curmoment = 0;
forward = !forward;
}
}
else
{
if(curmoment == 400 && firstround)
{
curmoment = 0;
forward = !forward;
firstround = false;
}
else if(curmoment == 8000)
{
curmoment = 0;
forward = !forward;
}
}

curmoment += 1;


if(forward)
Position += velocity;
else
Position -= velocity;

GetMeshNode()->setPosition(Position);
cam->setTarget(Position);
//cam->setPosition(Position - velocity);
}

void Player::SetPosition(vector3df newpos)
{
Position = newpos;
GetMeshNode()->setPosition(Position);
}

CEngine.cpp
Code: [Select]
#include "CEngine.h"

void CEngine::Draw()
{
driver->beginScene(true,true,SColor(0,0,100,200));
smgr->drawAll();
driver->endScene();
}

void CEngine::Load()
{
smgr->loadScene("models/myscene.irr");
Plr.Load("models/box.md2",smgr,driver);
Plr.SetTexture("models/textures/box_texture.tga",driver);
camera = smgr->addCameraSceneNode(0,vector3df(5,0,0));

}

void CEngine::Update()
{
Plr.UpdateVariables(GetCamera());
}

void CEngine::Unload()
{
Plr.Unload();
device->drop();
}

void CEngine::Init(const wchar_t * text)
{
IrrlichtDevice * dev = createDevice(EDT_DIRECT3D9,dimension2d<u32>(640,480),16,false,false,false/*,eventhandler*/);
dev->run();
if(!dev)
{
printf("Device Failed");
return;
}

dev->setWindowCaption(text);
driver = dev->getVideoDriver();
smgr = dev->getSceneManager();
device = dev;
}

ICameraSceneNode * CEngine::GetCamera()
{
return camera;
}




And Here Are The Errors:
Code: [Select]
------ Build started: Project: Irrlicht, Configuration: Release Win32 ------
Compiling...
Player.cpp
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C2146: syntax error : missing ';' before identifier 'Plr'
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
main.cpp
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C2146: syntax error : missing ';' before identifier 'Plr'
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(15) : error C2504: 'Model3D' : base class undefined
EventHandler.cpp
CEngine.cpp
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(15) : error C2504: 'Model3D' : base class undefined
.\CEngine.cpp(13) : error C2039: 'Load' : is not a member of 'Player'
        c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(14) : see declaration of 'Player'
.\CEngine.cpp(14) : error C2039: 'SetTexture' : is not a member of 'Player'
        c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(14) : see declaration of 'Player'
.\CEngine.cpp(26) : error C2039: 'Unload' : is not a member of 'Player'
        c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(14) : see declaration of 'Player'
3DModel.cpp
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C2146: syntax error : missing ';' before identifier 'Plr'
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\CEngine.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\kimberly the genius!\desktop\opengl\irrlicht\irrlicht\Player.h(15) : error C2504: 'Model3D' : base class undefined
Build log was saved at "file://c:\Documents and Settings\Kimberly the Genius!\Desktop\OpenGL\Irrlicht\Irrlicht\Release\BuildLog.htm"
Irrlicht - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

9
Beta Releases / Richochet - Xbox 360 Game(On Computer)
« on: May 04, 2010, 09:41:34 pm »
I've been working on a game of mine called Richochet.

The point of Richochet is to use your skills to shoot out your red balls(which will richochet off of walls) and be reward 1 point for each one shot off.  And then you must dodge the balls as they continuously bounce off the walls.  You can also shoot a blue ball, which will last for 15 seconds and will destroy any red balls it touches.  The red balls will also assimilate themselves into the other red balls to make bigger(harder to dodge) and more damaging balls.  You have a speed boost ability also, and a healthbar.

Not a great UI, but its not the worst in the world.

Controls

Left Stick - Move around the screen.
Right Stick - Aim your cannon
Right Trigger - Shoot Gun
Left Trigger - Speed Boost
Left Bumper + Right Trigger - Shoot blue ball (cost 10pts) (they heal you)

Software Requirements
Xna 3.0
Xbox 360 Controller Software

Hardware Requirements
Xbox 360 Controller

Download Game

- EDIT - Fixed the links for you.


[edited name=Celestialkey date=1273027404][/edited]
[edited name=Celestialkey date=1273027445][/edited]
[edited name=Celestialkey date=1273027577][/edited]
[edited name=mager1794 date=1273027964][/edited]
[edited name=mager1794 date=1273028155][/edited]

10
XNA / Xna Tutorial 1: Opening The Door
« on: May 02, 2010, 11:13:37 am »
Xna Tutorial 1: Opening The Door

The 'door' is what were going to open with in tutorial 1.  By the door I simply mean
the pathway into Xna Programming, needs to be recognized and understood.  You must
know the tools that your working with first and foremost.  We will be using Xna 3.0
and Visual C# Express 2008 (2003 + 2005 - will not work| I have no idea about Visual
Studio 2010).  These are all very simple programs to use, especially compared to what
you would have to do without them.

What we'll be working with is Windows Games for computers.  Which means we will not
be using Xbox 360 or The Zune. Sorry if thats what you wanted, but these can be
easily ported to Xbox 360 and The Zune, so no harm no foul.

Well to open this tutorial were gonna make what is called the "Game Over!" Program.
Its the exact same concept as "Hello, World" but its got the game programming twist.

- Lets begin by running Visual C# Express 2008

Excellent! Time For Step 2

- Click File -> New Project

- Your Project Selection Dialog Should be open now
- Click The Xna Game Studio 3.0 Tree Node
- Select Windows Game(3.0)

Next were gonna wanna draw some text onto the screen. To do so we need to add a
SpriteFont

- Right Click Your Content Node -> Add New Item
- Select SpriteFont And Name It Font

Look for this text
Code: [Select]
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

And turn it into this

Code: [Select]
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        SpriteFont Font;

Now we've defined our SpriteFont, lets load its content

- Go Down to Load Content and type this in

Code: [Select]
Font = Content.Load<SpriteFont>("Font");

There we go, now all the Font Variables have been defined.
Lets Code the game over message, so go down to your Draw function

Code: [Select]
spriteBatch.Begin();

spriteBatch.End();

Add that after

Code: [Select]
GraphicsDevice.Clear(Color.CornflowerBlue);

In between the space where you began and ended your spriteBatch, is where all of
your drawing will occur, now lets draw a string

Code: [Select]
spriteBatch.DrawString(Font, "Game Over!", new Vector2(340,300), Color.Red);

Now To See what we've made, Press F5


Congratulations, You Got A Game Over!!!! Wait....that doesn't sound right.

Tune In For More Tutorials Coming From Me

11
Code Snipplets / [SDL] Play Sound Effect
« on: March 07, 2010, 07:42:03 pm »
I wrote a custom class to play  sound effects using SDL.


SoundEffect.h
Code: [Select]
#include "SDL.h"
#include "SDL_mixer.h"

class SoundEffect
{
public:
void Load(const char* file);
void Play(int loop = 1);
bool OpenAudio();//Only needs to be ran once, and must be ran before any sound effect functions will work
void DestroyChunk();//Be sure to run this before closing SDL
void CloseAudio();//Be sure to run this before closing SDL
void SetVolume(int volume);


private:
Mix_Chunk *effect;
};

SoundEffects.cpp
Code: [Select]
//Include SDL functions and datatypes
#include "SDL.h"
#include "SDL_mixer.h"
#include "SoundEffect.h"

void SoundEffect::DestroyChunk()
{
Mix_FreeChunk(effect);
}

void SoundEffect::CloseAudio()
{
Mix_CloseAudio();
}

void SoundEffect::SetVolume(int volume)
{
Mix_VolumeChunk(effect, volume);
}

bool SoundEffect::OpenAudio()
{
bool returnval = true;
if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 ) { returnval = false; }

return returnval;

}

void SoundEffect::Play(int loop)
{
Mix_PlayChannel( -1, effect, loop);
}

void SoundEffect::Load(const char* file)
{
effect = Mix_LoadWAV(file);
}

main.cpp
Code: [Select]
//Include SDL functions and datatypes
#include "SDL.h"
#include "SDL_mixer.h"
#include "SoundEffect.h"

int main( int argc, char* args[] )
{
SoundEffect fx;//my object to hold my sfx
SDL_Surface* screen = NULL;

//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

        //Open Audio
        // Do not not open this again(event for another SoundEffect) until you close the Audio
fx.OpenAudio();

SDL_WM_SetCaption("Play sound and show dude", NULL);
//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

fx.Load( "high.wav" );//Load our file

for(int i = 0; i < 5;i++)
{
fx.SetVolume(i*50);//Set the volume
fx.Play();// Default Play Once
SDL_Delay(1000);
}

fx.Play(6);

//Pause
SDL_Delay( 2000 );

fx.DestroyChunk();//Destroy our SoundEffect

fx.CloseAudio();//Close the audio

//Quit SDL
SDL_Quit();
return 0;
}

12
Challenges / Simple Text Based RPG [Kinda]
« on: March 06, 2010, 02:14:20 pm »
I studyed C++ a bit and after working pretty hard i'd say lol

I created a tiny RPG like game played in a console

enjoy

Code: C++
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int Levels[10] = {0,50,150,250,500,750,1000,2000,2500,5000};
  7. int PlrHp[10] = {0,50,100,200,400,800,1000,1200,2000,2500};
  8. int CHp[10] = {0,30,50,100,125,150,150,200,250,500};
  9. int CDmg[10] = {0,5,7,10,12,17,22,27,35,50};
  10. bool b_continue = true;
  11. bool b_created = true;
  12. bool b_battle = true;
  13.  
  14. class Player            // class definition -- defines a new type, Critter
  15. {
  16. public:
  17.     string Name;
  18.     int Energy;
  19.     int Class;
  20.     int Level;
  21.     int Hp;
  22.     int Xp;
  23.     int aatkdmg;
  24.     int batkdmg;
  25.     int catkdmg;
  26.     string Attacks;
  27.     string ClassName;
  28.     void Attack(int type);
  29. };
  30.  
  31. Player user;
  32.  
  33. class Creature           // class definition -- defines a new type, Critter
  34. {
  35. public:
  36.     int Level;
  37.     int Hp;
  38.     int Xp;
  39.     int dmg;
  40.     void Create();
  41. };
  42.  
  43. void Creature::Create()
  44. {
  45.      Level = user.Level;
  46.      srand(time(0));
  47.      int nxp = ((rand() % (50 * Level)) + 20) ;
  48.      Xp = nxp;
  49.      Hp = ((rand() % CHp[Level]));
  50.      if(Hp < 15)
  51.            Hp += 20;
  52.      dmg = CDmg[Level];
  53. }
  54.  
  55. Creature creat;
  56.  
  57.  
  58.  
  59.  
  60. void Player::Attack(int type)
  61. {
  62.      cout << "\n\n";
  63.      if(type == 0)
  64.      {
  65.              int pdmg = (rand()%(aatkdmg * Level));
  66.              if(pdmg == 0)
  67.                      cout << "Your attack missed\n";
  68.              else
  69.              {
  70.              creat.Hp -= pdmg;
  71.              cout << "You attacked the creature for " << pdmg << " damage\n";
  72.              }
  73.      }
  74.      else if(type == 1)
  75.      {
  76.           int pdmg = (rand()%(batkdmg * Level));
  77.               if(pdmg == 0)
  78.               {
  79.                      cout << "Your attack missed\n";
  80.                      if(Energy >= 5)
  81.                      {
  82.                                Energy -= 5;
  83.                      }
  84.               }
  85.              else
  86.              {
  87.                  if(Energy >= 5)
  88.                  {
  89.                  creat.Hp -= pdmg;
  90.                  cout << "You attacked the creature for " << pdmg << " damage\n";
  91.              
  92.                  Energy -= 5;
  93.                  }
  94.                  else
  95.                  {
  96.                      cout << "Not enough energy, turn lost";
  97.                  }
  98.                }
  99.      }
  100.      else if(type == 2)
  101.      {
  102.           int pdmg = (rand()%(catkdmg * Level));
  103.               if(pdmg == 0)
  104.               {
  105.                      cout << "Your attack missed\n";
  106.                      if(Energy >= 10)
  107.                      {
  108.                                Energy -= 10;
  109.                      }
  110.               }
  111.              else
  112.              {
  113.                  if(Energy >= 10)
  114.                  {
  115.                  creat.Hp -= pdmg;
  116.                  cout << "You attacked the creature for " << pdmg << " damage\n";
  117.                  Energy -= 10;
  118.                  }
  119.                  else
  120.                  {
  121.                  cout << "Not enough energy, turn lost";
  122.                  }
  123.              }
  124.      }
  125.      int dmg = ((rand() % creat.dmg));
  126.      if(dmg == 0)
  127.             cout << "The creatures attack missed\n";
  128.      else
  129.      {
  130.      Hp -= dmg;
  131.      cout << "The Creature attacked you for " << dmg << " damage \n";
  132.      
  133.      }
  134.      cout << "You have " << Hp << " left and "<< Energy << " energy left\nThe creature has " << creat.Hp << " left\n\n";
  135. }
  136.  
  137.  
  138.  
  139.  
  140. int main()
  141. {
  142.     while(b_continue)
  143.     {
  144.                if(b_created)
  145.                {
  146.                             cout << "What is your name?" << endl;
  147.                             cin >> user.Name;
  148.                             cout << "Pick A Class\n\t0 - Warrior\n\t1 - Rogue\n\t2 - Mage\n";
  149.                             int cinclass;
  150.                             cin >> cinclass;
  151.                             user.Class = cinclass;
  152.                             if(cinclass == 0)
  153.                                         user.ClassName = "Warrior";
  154.                             else if(cinclass == 1)
  155.                                    user.ClassName = "Rogue";
  156.                             else if(cinclass == 2)
  157.                                  user.ClassName = "Mage";
  158.                             else
  159.                             {
  160.                                 cout << "Class out of range, Warrior assumed\n";
  161.                                 user.ClassName = "Warrior";
  162.                                 user.Class = 0;
  163.                             }
  164.                             user.Level = 1;
  165.                             user.Xp = 0;
  166.                             if(user.Class == 2)
  167.                             {
  168.                             user.Attacks = "0 - Fireball\n1 - Ice Dart\n2 - Shadow Blast\n";
  169.                             }
  170.                             else if(user.Class ==
  171.                              1)
  172.                             {
  173.                                  user.Attacks = "0 - Shank\n1 - Backstab\n2 - Rupture\n";
  174.                             }
  175.                             else
  176.                             {
  177.                                 user.Attacks = "0 - Swift Cut\n1 - Shield Bask\n2 - Power Swing\n";
  178.                             }
  179.                            
  180.                             user.Attacks = "Pick an attack\n" + user.Attacks;
  181.                             user.Hp = 50;
  182.                             user.aatkdmg = 3;
  183.                             user.batkdmg = 5;
  184.                             user.catkdmg = 10;
  185.                             user.Energy = 75;
  186.                              b_created = false;    
  187.                              system("cls");          
  188.                }
  189.                
  190.                cout << "Welcome " << user.Name << ", Your adventure begins here.  It is your duty as a young " << user.ClassName << " to shone your skills and become one of the best of the best.  By simply walking \naround, you must face predators to gain immense strength, if you accept this \ntask.....continue\n\n";
  191.                system("pause");
  192.                system("cls");
  193.                cout << "Let the battle begin!!\n";
  194.                
  195.                creat.Create();
  196.                
  197.                while(b_battle)
  198.                {
  199.                 if(user.Hp <= 0)
  200.                 {
  201.                            cout << "You have lost the battle, your adventure is over";
  202.                            b_continue = false;
  203.                            b_created =false;
  204.                            b_battle = false;
  205.                            
  206.                 }
  207.                 else if(creat.Hp <= 0)
  208.                 {
  209.                      cout << "You have emerged victorius\n";
  210.                      cout << "Experience Gained: " << creat.Xp << "\n";
  211.                      user.Xp += creat.Xp;
  212.                      if(user.Xp >= Levels[user.Level])
  213.                      {
  214.                                 user.Level += 1;
  215.                                 cout << "You have gained a level and are now level " << user.Level << endl;
  216.                      }
  217.                      user.Hp = PlrHp[user.Level];
  218.                      user.Energy = 75;
  219.                      cout << "\n\n\n";
  220.                      system("pause");
  221.                      system("cls");
  222.                      creat.Create();
  223.                 }
  224.                 else
  225.                 {
  226.                 cout << user.Attacks;
  227.                 int attack = 4;
  228.                 while(attack >= 3)
  229.                 {
  230.                  cin >> attack;
  231.                  if(attack < 3)
  232.                            user.Attack(attack);
  233.                 }
  234.                
  235.                
  236.                 }
  237.                }
  238.                
  239.                
  240.                
  241.     }
  242.     return 0;
  243. }
  244.  
  245.  
  246.  

13
Challenges / [Personal Challenge] Scripting Language
« on: February 13, 2010, 10:01:41 pm »
Well, I decided to challenge myself to kinda make a scripting langauge, this will be a project of mine for probably quite a while.  Mostly  because im grounded, but also because its a long process.  This isn't to make a worldwide popular language or nothing.  Just to see if i can do it.

Current Progress

- Variable Reading, storaging
- Message Box function

Ex.
Code: [Select]
var m = "Well, hello there dude"
; msg(m)

This is fully static so you dont have to create a new Class

Compiler.cs
Code: C#
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6.  
  7. namespace ScriptCompiler
  8. {
  9.     static class Compiler
  10.     {
  11.         static ListBox varnames;
  12.         static ListBox varvalues;
  13.         static string errors = "";
  14.  
  15.         static public void Compile(string script)
  16.         {
  17.             errors = "";
  18.             varnames = new ListBox();
  19.             varvalues = new ListBox();
  20.             string[] lines = script.Split('\n');
  21.  
  22.             foreach (string line in lines)
  23.             {
  24.                 string nline = line.Replace(" ", "");
  25.                 if (nline.StartsWith("var"))
  26.                 {
  27.                     ParseVariable(line);
  28.                 }
  29.                 else if (nline.StartsWith(";msg"))
  30.                 {
  31.                     string l = line.Replace(" ", "");
  32.                     SayVariable(l);
  33.                 }
  34.                 else if (nline.StartsWith(";"))
  35.                 {
  36.                     errors = errors + "Syntax Error: Function doesn't exist\n";
  37.                 }
  38.  
  39.  
  40.             }
  41.  
  42.             ErrorWork();
  43.  
  44.         }
  45.  
  46.         static private void ErrorWork()
  47.         {
  48.             if(errors != "")
  49.                 MessageBox.Show(errors);
  50.         }
  51.  
  52.         static private void SayVariable(string line)
  53.         {
  54.             line = line.Replace(";", "");
  55.             line = line.Replace("\r", "").Replace("msg(", "").Replace(")", "");
  56.             int index = varnames.FindString(line);
  57.             if (index == -1)
  58.             {
  59.                 errors = errors + "Unexisting variable referenced\n";
  60.             }
  61.             else
  62.             {
  63.                 object val = varvalues.Items[index];
  64.                 MessageBox.Show(val.ToString());
  65.             }
  66.         }
  67.  
  68.  
  69.         static private void ParseVariable(string line)
  70.         {
  71.             line = line.Replace("var ", "");
  72.             string[] switchs = line.Split(' ');
  73.             line = line.Replace(switchs[0] + " ", switchs[0]);
  74.             switchs = line.Split(' ');
  75.             line = line.Replace(switchs[0] + " ", switchs[0]);
  76.            
  77.             string[] seperate = line.Split('=');
  78.             varnames.Items.Add(seperate[0]);
  79.             varvalues.Items.Add(seperate[1].Replace('"',' '));
  80.         }
  81.     }
  82. }
  83.  

14
Challenges / [C++] Console Calculator
« on: January 23, 2010, 12:35:43 am »
Followed the tutorials up to 10 [Time for a review!]

and saw celest make a calculator and i decided to attempt it myself, was a pretty simple project
really

Code: C++
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. void Start();
  7. void Exit();
  8. void GetMethod(int option);
  9. void Add(int x, int y);
  10. void Sub(int x, int y);
  11. void Mul(int x, int y);
  12. void Div(int x, int y);
  13.  
  14. int main()
  15. {
  16.         // Opening Message
  17.         // Welcome to the Console Calculator
  18.         cout << "Welcome to the Console Calculator" << endl << endl;
  19.        
  20.         // Start the program logic
  21.         // Display starting screen
  22.         Start();
  23.         return 0;
  24. }
  25.  
  26. void Start()
  27. {
  28.         //Never Ending Loop
  29.         //Requires Manual Program Exit
  30.  
  31.         while(1)
  32.         {
  33.                 cout << "Please select an action to perform" << endl;
  34.                 cout << "        1: Addition" << endl;
  35.                 cout << "        2: Subtraction" << endl;
  36.                 cout << "        3: Multiplication" << endl;
  37.                 cout << "        4: Division" << endl;
  38.                 cout << "        0: Exit" << endl << endl;
  39.                 int option;
  40.                 cin >> option;
  41.                 cout << endl;
  42.                 if(option >= 1)
  43.                 {
  44.                         GetMethod(option);
  45.                 }
  46.                 else
  47.                 {  
  48.                         Exit();
  49.                             break;  
  50.                 }
  51.         }
  52. }
  53.  
  54. void GetMethod(int option)
  55. {
  56.         //Get the numbers to work with
  57.        
  58.         // Define them here
  59.         int x;
  60.         int y;
  61.  
  62.         if(option > 4)
  63.         {
  64.                 cout << "The option entered doesn't exist" << endl << endl;
  65.         }
  66.         else
  67.         {
  68.         // Ask for x
  69.         cout << "Please enter your first number" << endl << endl;
  70.         cin >> x;
  71.         cout << endl;
  72.         cout << "Please enter your second number" << endl << endl;
  73.         cin >> y;
  74.         cout << endl;
  75.  
  76.         // use switch method
  77.         // easier than typing if and else over and over
  78.         switch(option)
  79.         {
  80.         case 1:
  81.                 //Set Addition Logic
  82.                 Add(x,y);
  83.                 break;
  84.  
  85.         case 2:
  86.                 //Set Subtraction Logic
  87.                 Sub(x,y);
  88.                 break;
  89.  
  90.         case 3:
  91.                 //Set Multiplication Logic
  92.                 Mul(x,y);
  93.                 break;
  94.  
  95.         case 4:
  96.                 //Set Division Logic
  97.                 Div(x,y);
  98.                 break;
  99.         }
  100.         }
  101. }
  102.  
  103. void Add(int x, int y)
  104. {
  105.         // Add X + Y
  106.         cout << "The answer is: " << (x+y) << endl << endl;
  107. }
  108.  
  109. void Sub(int x, int y)
  110. {
  111.         // Subtract X - Y
  112.         cout << "The answer is: " << (x-y) << endl << endl;
  113. }
  114.  
  115. void Mul(int x, int y)
  116. {
  117.         // Multiply X * Y
  118.         cout << "The answer is: " << (x*y) << endl << endl;
  119. }
  120.  
  121. void Div(int x, int y)
  122. {
  123.         // Divide X / Y
  124.         cout << "The answer is: " << (x/y) << endl << endl;
  125. }
  126.  
  127. void Exit()
  128. {
  129.                                 // Taken from Celestials Calculator
  130.                         // Tis a good method :)
  131.                                  system("cls");   // Clear the screen  
  132.                      cout << "\n\n\n\n\n\n\n";  
  133.                      cout << "     Exiting Calculator";  
  134.                      cout << "\n\n\n\n\n";  
  135.                      system("pause");  
  136. }
  137.  

15
Challenges / Tic-Tac Toe [Basic AI]
« on: September 14, 2009, 08:24:46 pm »
I have developed a basic AI in the form of tic-tac toe

It works perfectly fine, as long as the game isn't a tie, for some reason the program freezes in the event of a tie
so i put the reset button there in the event you feel you may tie.

The code is in the .rar file and the program is the .exe

16
Code Snipplets / Tabbing Feature [Something of Own Choice]
« on: September 14, 2009, 03:19:45 pm »
i decided to pick the tabbing feature i developed a long time ago and have been using ever since, for my Something of your own choice.

If you like the code i don't mind if you use it, so have at it.


Code: [Select]
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.tabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.addTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.deleteTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.addTabToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.removeTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.menuStrip1.SuspendLayout();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.tabToolStripMenuItem,
            this.editToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(292, 24);
            this.menuStrip1.TabIndex = 0;
            this.menuStrip1.Text = "menuStrip1";
            //
            // tabToolStripMenuItem
            //
            this.tabToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.addTabToolStripMenuItem,
            this.deleteTabToolStripMenuItem});
            this.tabToolStripMenuItem.Name = "tabToolStripMenuItem";
            this.tabToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.tabToolStripMenuItem.Text = "Tab";
            //
            // addTabToolStripMenuItem
            //
            this.addTabToolStripMenuItem.Name = "addTabToolStripMenuItem";
            this.addTabToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
            this.addTabToolStripMenuItem.Text = "Add Tab";
            this.addTabToolStripMenuItem.Click += new System.EventHandler(this.addTabToolStripMenuItem_Click);
            //
            // deleteTabToolStripMenuItem
            //
            this.deleteTabToolStripMenuItem.Name = "deleteTabToolStripMenuItem";
            this.deleteTabToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
            this.deleteTabToolStripMenuItem.Text = "Delete Tab";
            this.deleteTabToolStripMenuItem.Click += new System.EventHandler(this.deleteTabToolStripMenuItem_Click);
            //
            // editToolStripMenuItem
            //
            this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.undoToolStripMenuItem});
            this.editToolStripMenuItem.Name = "editToolStripMenuItem";
            this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.editToolStripMenuItem.Text = "Edit";
            //
            // undoToolStripMenuItem
            //
            this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
            this.undoToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
            this.undoToolStripMenuItem.Text = "Undo";
            this.undoToolStripMenuItem.Click += new System.EventHandler(this.undoToolStripMenuItem_Click);
            //
            // tabControl1
            //
            this.tabControl1.ContextMenuStrip = this.contextMenuStrip1;
            this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControl1.Location = new System.Drawing.Point(0, 24);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(292, 242);
            this.tabControl1.TabIndex = 1;
            //
            // contextMenuStrip1
            //
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.addTabToolStripMenuItem1,
            this.removeTabToolStripMenuItem});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(146, 48);
            //
            // addTabToolStripMenuItem1
            //
            this.addTabToolStripMenuItem1.Name = "addTabToolStripMenuItem1";
            this.addTabToolStripMenuItem1.Size = new System.Drawing.Size(145, 22);
            this.addTabToolStripMenuItem1.Text = "Add Tab";
            this.addTabToolStripMenuItem1.Click += new System.EventHandler(this.addTabToolStripMenuItem_Click);
            //
            // removeTabToolStripMenuItem
            //
            this.removeTabToolStripMenuItem.Name = "removeTabToolStripMenuItem";
            this.removeTabToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
            this.removeTabToolStripMenuItem.Text = "Remove Tab";
            this.removeTabToolStripMenuItem.Click += new System.EventHandler(this.deleteTabToolStripMenuItem_Click);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.tabControl1);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "Form1";
            this.Text = "Form1";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.TabControl tabControl1;
        private System.Windows.Forms.ToolStripMenuItem tabToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem addTabToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem deleteTabToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.ToolStripMenuItem addTabToolStripMenuItem1;
        private System.Windows.Forms.ToolStripMenuItem removeTabToolStripMenuItem;

17
Challenges / Noise Generator [C#]
« on: September 14, 2009, 02:38:55 pm »
Today i though i would tackle one of the easy tasks, my goal is to knock all them off by the end of the week and move on the the next one.

Today i decided to use the noise generator.  I decided to use the Console.Beep(frequency, duration), method to accomplish this.

I gave a DomainUpDown box to scroll through the duration (max is 10 seconds)
and a track bar to move through the sound frequencys

Enjoy


Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Noise_Generator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BackgroundWorker backgroundWorker = new BackgroundWorker();
            backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
            backgroundWorker.RunWorkerAsync();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            textBox1.Text = trackBar1.Value.ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int i;
            for (i = 10; i > 0; i--)
            {
                domainUpDown1.Items.Add(i);
            }

            domainUpDown1.SelectedIndex = 9;
        }

        #region DesignCode
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.trackBar1 = new System.Windows.Forms.TrackBar();
            this.label1 = new System.Windows.Forms.Label();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.domainUpDown1 = new System.Windows.Forms.DomainUpDown();
            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(194, 133);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "Beep";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // trackBar1
            //
            this.trackBar1.Location = new System.Drawing.Point(5, 82);
            this.trackBar1.Maximum = 32767;
            this.trackBar1.Minimum = 37;
            this.trackBar1.Name = "trackBar1";
            this.trackBar1.Size = new System.Drawing.Size(278, 45);
            this.trackBar1.TabIndex = 1;
            this.trackBar1.TickFrequency = 800;
            this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
            this.trackBar1.Value = 37;
            this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(2, 55);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(57, 13);
            this.label1.TabIndex = 2;
            this.label1.Text = "Frequency";
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(65, 48);
            this.textBox1.Name = "textBox1";
            this.textBox1.ReadOnly = true;
            this.textBox1.Size = new System.Drawing.Size(111, 20);
            this.textBox1.TabIndex = 3;
            this.textBox1.Text = "37";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(2, 9);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(64, 26);
            this.label2.TabIndex = 4;
            this.label2.Text = "Duration\r\n(in seconds)";
            //
            // domainUpDown1
            //
            this.domainUpDown1.Location = new System.Drawing.Point(72, 15);
            this.domainUpDown1.Name = "domainUpDown1";
            this.domainUpDown1.Size = new System.Drawing.Size(94, 20);
            this.domainUpDown1.TabIndex = 5;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(281, 175);
            this.Controls.Add(this.domainUpDown1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.trackBar1);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.Text = "Noise Generator";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.TrackBar trackBar1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.DomainUpDown domainUpDown1;
        #endregion

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Console.Beep(int.Parse(textBox1.Text), (int.Parse(domainUpDown1.Text) * 1000));
            }
            catch { }
            finally
            {
                ((BackgroundWorker)sender).Dispose();
            }
        }
    }
}


Made a quick edit to prevent the code from clashing and throwing errors

18
Project Advertisment / Find Dialog
« on: September 13, 2009, 03:36:52 pm »
Well I've decided to develop a Find Dialog Box for the community, thing is I'm gonna probably need some help from time to time, so if this isn't against the rules.  I'd like to keep this thread open til i finish the dialog.  After creating a working find, then i plan on also making a replace for it as well.  So anyone in need of these stay tuned.

19
Beta Releases / Tutorial Maker v1.0.0
« on: March 27, 2009, 10:29:39 pm »
this is a program i wrote to parse BB Code and then view it inside another tab
it is not completely finished but i do have the main code tags included......i think

List
Code: [Select]
bold   
italic
center
marquee
url
code   
size   
color 
image 

the download is at the bottom of the page

credits to Code Parser
for making the code parser.....hoping to in v2.0.0 to have created my own by then


20
Challenges / Encryptor/Decryptor [C#]
« on: March 20, 2009, 12:40:52 am »
It doesn't look like much because i always use library files to make work easier for me : )

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
using Encypt;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string cipherText = Cryptographication.Encrypt(textBox1.Text);
                                                 

            MessageBox.Show(String.Format("{0}",cipherText));
            textBox2.Text = String.Format("{0}", cipherText);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string cipherText = Cryptographication.Decrypt(textBox2.Text);

            MessageBox.Show(String.Format("{0}", cipherText));
        }
    }
}


21
Challenges / Simple Beep [C#]
« on: March 19, 2009, 10:53:45 pm »
Code: [Select]
[CODE]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Beep
{
    class ConsoleBeep
    {
        [STAThread]
        static void Main()
        {
            Console.Beep(500,2000);
            Console.Write("I just beeped");
            Console.Read();
        }
    }
}

Clearly relatively simple code just trying to knock out some of the challenges in my spare time[/code]

22
XNA / XNA Tutorial Series - Graphics [1]
« on: March 17, 2009, 02:22:36 pm »
Graphics Introduction

Okay in this tutorial were gonna learn how to after making the
graphics(i have it premade for your use). To place it onto
the games screen then we will use the keyboard to make it move


Getting Started

Make your project the same way i showed you in the introduction
and just because i was the moron that never thought of this
i'm gonna tell you how to change the name of the game on the window

Click the +Properties
and Open AsseblyInfo.cs


This is all you need to edit at your own will of course


okay download this image and save it to your desktop or where ever you choose and name it "Ball.png"



Next were gonna right click the Content Menu item in your solution explorer click Content->Add->Existing Item and
and the ball to your project

Now scroll to the point in Game1.cs where you see :
 


Code: [Select]
Texture2D ball;

add that after SpriteBatch spriteBatch;

then scroll down to

Code: [Select]
protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
        }



inside the void after the sprite batch enter this

Code: [Select]
ball = Content.Load<Texture2D>("Ball");

Next were gonna move on to drawing the ball on the screen

go down to

Code: [Select]
protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }

after the
//TODO: Ad your drawing code here
enter this:

Code: [Select]
spriteBatch.Begin();
                spriteBatch.Draw(ball, new Vector2(200,300), Color.White);
            spriteBatch.End();

then run the game
you see your little ball on the blue screen but unfortunately it does nothing and thats no fun at all so lets get onto movement

in the same spot where you put the Texture2D ball;
place


Code: [Select]
KeyboardState currentKeyboard;
KeyboardState oldKeyboard;

now go down to the initialize function and enter this inside it

Code: [Select]
currentKeyboard = new KeyboardState();
oldKeyboard = new KeyboardState();

go to the Update function and lets place this inside it

Code: [Select]
oldKeyboard = currentKeyboard;
currentKeyboard = Keyboard.GetState();

now go to the bottom directly under draw and enter this code

Code: [Select]

public bool IsHeld(Keys key)
        {
            if (currentKeyboard.IsKeyDown(key))
            {
               return true;
            }
            else
            {
                return false;
            }
        }
public bool IsReleased(Keys key)
        {
            if (currentKeyboard.IsKeyUp(key)&&oldKeyboard.IsKeyDown(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
public bool JustPressed(Keys key)
        {
            if (currentKeyboard.IsKeyDown(key)&&oldKeyboard.IsKeyUp(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

okay now we need to create a special class for the ball

so after the final bracket in Game1 class put this

Code: [Select]
public class Ball
    {
        public Point Position;
        public int xSpeed;
        public int ySpeed;


        public Ball(Point position)
        {
            Position = position;
        }

        public void UpdateBall()
        {
            Position.X += xSpeed;
            Position.Y += ySpeed;
        }
    }

now go back above initialize where we declare everything and declare this

Code: [Select]
Ball objball;

In initialize enter this

Code: [Select]
objball = new Ball(new Point(200,100));

in update add this code this is what will make the ball move

Code: [Select]
if (IsHeld(Keys.Up))
            {
                objball.Position.X += -2;
            }
            if (IsHeld(Keys.Down))
            {
                objball.Position.X += 2;
            }
            if (IsHeld(Keys.Left))
            {
                objball.Position.Y += -2;
            }
            if (IsHeld(Keys.Right))
            {
                objball.Position.Y += 2;
            }

now go to the draw and change

Code: [Select]
spriteBatch.Draw(ball, new Vector2(ball., Color.White);

to
[color]
Code: [Select]
spriteBatch.Draw(ball, new Vector2(objball.Position.Y,objball.Position.X), Color.White);

now run the code and move the ball around notice that it doesn't stop if it goes outside the wall we will fix that in a later tutorial of mine

Heres the full code for this tutorial
[color]
Code: [Select]

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Texture2D ball;
        KeyboardState currentKeyboard;
        KeyboardState oldKeyboard;
        Ball objball;


        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            currentKeyboard = new KeyboardState();
            oldKeyboard = new KeyboardState();
            objball = new Ball(new Point(200, 100));
            base.Initialize();
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ball = Content.Load<Texture2D>("Ball");
            // TODO: use this.Content to load your game content here
        }

        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            oldKeyboard = currentKeyboard;
            currentKeyboard = Keyboard.GetState();
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            if (IsHeld(Keys.Up))
            {
                objball.Position.X += -2;
            }
            if (IsHeld(Keys.Down))
            {
                objball.Position.X += 2;
            }
            if (IsHeld(Keys.Left))
            {
                objball.Position.Y += -2;
            }
            if (IsHeld(Keys.Right))
            {
                objball.Position.Y += 2;
            }
            // TODO: Add your update logic here
            objball.UpdateBall();
            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            // TODO: Add your drawing code here
            spriteBatch.Begin();
                spriteBatch.Draw(ball, new Vector2(objball.Position.Y,objball.Position.X), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
        public bool IsHeld(Keys key)
        {
            if (currentKeyboard.IsKeyDown(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool IsReleased(Keys key)
        {
            if (currentKeyboard.IsKeyUp(key) && oldKeyboard.IsKeyDown(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool JustPressed(Keys key)
        {
            if (currentKeyboard.IsKeyDown(key) && oldKeyboard.IsKeyUp(key))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
    public class Ball
    {
        public Point Position;
        public int xSpeed;
        public int ySpeed;

        public Ball(Point position)
        {
            Position = position;
        }

        public void UpdateBall()
        {
            Position.X += xSpeed;
            Position.Y += ySpeed;
        }

    }
}


[/color]

23
XNA / XNA Tutorial Series Introduction
« on: March 17, 2009, 01:32:08 am »
XNA Introduction

Welcome to my XNA game programming tutorial series
now in this file i'm gonna just run down the method
of creating projects and managing files and telling
about each project file now if you wanna go the easy
way just read the next section but if you wish to
know in full depth the descriptions read the whole
introduction


[EASY ROAD]

Downloading And Installing

Ok first off you should already have Visual C# 2008 or 2005 or 2003 if not you probably shouldn't be here and need more prior knowledge of the programming language ok now go to creators.xna.com



Download XNA Game Studio 3.0
and run through the installing processes

Creating a Project

Ok to begin were gonna need to start visual C# 2008 express edition or which ever version you use after you do so
click the New Project button and select the "+" next to Visual C# and then click XNA Game Studio 30  and select Windows Game (3.0) And if your doing XNA you probably have prior knowledge of C# so you know how to do the names, location, etc.




now you have your project click F5 to debug and view it
it should look like this





[/EASY ROAD]

For those of you who chose to stick around lets look at
each of the projects and their uses

Windows Game -  Its a project to establish the layout for you to begin writing your game using Xna formats and methods if you
have prior C# knowledge you might be able to understand the code and go from where its ended and just write or you will probably need a tutorial to learn

Windows Game Library - Its the same as normal library files its a .dll file to store functions to cut down size of code used in one application at once its reached into for more info

Xbox360 Game - Well the name says it all and i know your thinking wow i can make a game for my xbox 360 awesome now, however true it is in order to debug using the xbox 360 requires member ship so its advised to just write your game in windows form and convert the controls used to xbox 360

Xbox360 Game Library - See Windows Game Library

Zune Game - Makes games for your zune or for others and for you to sell off to them if you choose to

Zune Game Library - See Windows Game Library

Content Pipeline Extension - An extension to help you control your content management i don't quite understand how to use this yet but i do plan to learn

Platform Starter Kit - Its a premade game that is a platform game an ex. is mario what you do with the game is look at its code to help yourself learn and then try to make your own or you can edit it yourself and add more stuff to it

Organization

This is a very small section

In order to keep things organized better you should try to keep things Organized in your content section with folders like these names

Sprite
Sounds
Effects
Fonts
Backgrounds




24
php / Php Information
« on: February 26, 2009, 07:33:36 pm »
Ok for alot of you people who are going to start learning Php or are maybe wanting to learn it lets talk
about some basic info about it

The point of php was to make a web scripting language capable of accessing and extracting information from an SQL Database.  Doing this gives you multiple capabilities such as making usernames and passwords for a forum or if you build a game based on SQL capabilites for an RPG you can use Php to create accounts for the game and not to mention create a small system of checks to make sure the account isn't being remade or something of the sort.

It gives many usable capabilities but is suggested to learn Html first since thats what you will use for the site design that it outputs

go to Php.net for more info
if your interested in learning search tutorials online to get you started

25
C# / [GUI 1] Hello World Tutorial
« on: February 26, 2009, 06:05:19 pm »
C# Introductory Tutorial

Yes i know you don't wanna hear this but its a hello world
script

now the catch to these tutorials is that well there not like

the other C# tutorials in that i will be doing Gui tutorials
and eventually even moving on the dll<class> tutorials

well to simply start why don't we open our C# program



place a button in the middle of the screen

you will find the button in the toolbox. 



Its all in Alphabetical order so its pretty simple to find

now double click the button

should see something along the lines of this



Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}


inside the private void button1_Click's curly brackets is where

we will enter our code

Now type



Code: [Select]
MessageBox.Show("Hello World!")


To view the script go to the toolbar and click Debug->Start Debugging or press F5

you will see something like this when you click the button



Now those who know VB.net you will notice how similar the
C# code is to VB.net but don't make the same mistake i made
in the transition and think the only difference will be some

brackets

that was a fairly easy script but it was required for us to

move on to more scripts

i plan on doing a Dll tutorial soon because they're extremely

important for better program organization


26
Project Advertisment / BBEditor [BBCode Parser & Editor]
« on: February 09, 2009, 06:34:51 pm »
I'm programming a parser in C# to take the BBcode typed in a richtextbox and replace it with something bolded or something

its gonna be similar to frontpage i have a demo up and ready with only the functions for

bold   
italic
center
marquee
url   
code- Not entirely functional
size   
color 
image 




like it will change this
[ b]
hey
[/b]

to


hey


heres kinda what i got so far all it is, is a parsing function for the bold

Code: [Select]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Drawing;

namespace BBCode
{
    public class BBTextBox : System.Windows.Forms.RichTextBox
    {
        private void ParseBoldText(RichTextBox tb)
        {
            ////Bold Parsing////
            int parseCount = 0;
            int lastStartPosition = 0;
            int currentPosition = 0;

            while (currentPosition < tb.Text.Length - 3)
            {
                if (tb.Text.Substring(currentPosition, 3) == "[b]")
                {
                    if (parseCount == 0)
                        lastStartPosition = currentPosition;
                    parseCount++;
                }
                if (tb.Text.Substring(currentPosition, 4) == "[/b]")
                {
                    parseCount--;
                    if (parseCount == 0)
                    {
                        tb.Select(lastStartPosition + 3, currentPosition - lastStartPosition - 3);
                        tb.SelectionFont = new Font(tb.SelectionFont.FontFamily, tb.SelectionFont.Size, tb.SelectionFont.Style | FontStyle.Bold);
                    }
                }
                currentPosition += 1;
            }

            //clean the <B> tags, carefulf to use the RTF property instead of TEXT property !!!!
            tb.Rtf = tb.Rtf.Replace("[b]", "");
            tb.Rtf = tb.Rtf.Replace("[/b]", "");
            /////End Parsing Bold

        }
    }
    public class BBCodeSettings
    {
        // Added In case i need....or want

    }
}

in the final version i will have hopefully all the BB code used on Celestial here finished : ) such as colors Code
etc.

If anyone is actually paying attention i'm hoping to release v1.0.0 soon

27
C# / Event Handling
« on: February 08, 2009, 06:58:24 pm »
Event Handling Tutorial
I. Introduction
II. Start
III. Choose Your Event
IV. Coding
V. Example


I. Introduction
In this tutorial I will be teaching you how to handle events such as  "OnMouseEnter" in
the programming language C#.  There are three requirements for this tutorial
  • A C# Compiler whether in IDE form or a simple console
  • A minimum of basic knowledge of C#
  • The desire to better your C# programming abilities

II. Start

Please open up what ever program you use to write C# files.  I use Visual Studio 2008 but you guys
can simply use what ever you wish

Create a WindowsFormApplication Project

Where you see code that looks like this

Code: [Select]
public Form1()
        {
            InitializeComponent();
        }



is where we will be writing our code

III. Choose Your Event

To choose your event(only works if you have visual studio) this is for using button1
this.button1.
and it will show a list of all the commands/properties/events for button1

find one of the items on the list that has a lightning bolt to the right of it and that's an event
for this tutorial i will use MouseEnter

IV. Coding

The coding of this is actually quite simple
under

Code: [Select]
public Form1()
        {
            InitializeComponent();


you will enter this


Code: [Select]
this.button1.MouseEnter += new System.EventHandler(this.button1_MouseEnter);


The MousEnter is the event that your registering the event handler to
and button1_MouseEnter is the function which you tell the program what to do


Code: [Select]
private void button1_MouseEnter(object sender, EventArgs e)
        {
        }


in between the brakets({,})
you will enter the code that you want to activate when the event happens

V. Example

Code: [Select]
namespace Example
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
            this.button2.MouseEnter += new System.EventHandler(this.button2_MouseOver);
            this.button2.MouseLeave += new System.EventHandler(this.button2_MouseLeave);
            this.button1.MouseEnter += new System.EventHandler(this.button1_MouseOver);
            this.button1.MouseLeave += new System.EventHandler(this.button1_MouseLeave);
        }

        private void button2_MouseOver(object sender, EventArgs e)
        {
            button2.BackColor = Color.Red;
            button2.ForeColor = Color.Green;
        }

        private void button2_MouseLeave(object sender, EventArgs e)
        {
            button2.BackColor = Color.Maroon;
            button2.ForeColor = Color.ForestGreen;
        }

        private void button1_MouseOver(object sender, EventArgs e)
        {
            button1.BackColor = Color.Red;
            button1.ForeColor = Color.Green;
        }

        private void button1_MouseLeave(object sender, EventArgs e)
        {
            button1.BackColor = Color.Maroon;
            button1.ForeColor = Color.ForestGreen;
        }




Well thanks alot for reading my tutorial i really hope you like it
please leave feedback at will or if necessary thank you
                               
                                                                         - Mager1794





28
Challenges / Guessing Game [C#]
« on: February 08, 2009, 04:38:25 pm »
Guessing Game Coded in C#

Here is a guessing game i coded in C# its one of the first things of done since my conversion from
VB.net to C#

Form1.cs

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GuessingGame
{
    public partial class Form1 : Form
    {
        Random number = new Random(); // This is declaring number; our randomizer
        int rn; // This is declaring rn; our randomized number
        int gn; // This is declaring gn; our guessed number
       
        public Form1()
        {
            InitializeComponent();
        }
        private void Control_MouseEnter(object sender, MouseEventArgs e)
        {
        }

        private void AddLose()
        {
            int lostamm = int.Parse(loses.Text);
            lostamm++;

            loses.Text = lostamm.ToString();
        }

        private void AddWin()
        {
            int winamm = int.Parse(wins.Text);
            winamm++;

            wins.Text = winamm.ToString();

        }

        public void SetHighScore()
        {
            int winamm = int.Parse(wins.Text);
            int lostamm = int.Parse(loses.Text);

            int highscore = winamm - lostamm;
            Properties.Settings.Default.highscore = highscore;
        }

        public int GetHighScore()
        {
            int highscore = Properties.Settings.Default.highscore;
            return highscore;
        }

        public int Score()
        {
            int winamm = int.Parse(wins.Text);
            int lostamm = int.Parse(loses.Text);

            int score = winamm - lostamm;
            return score;
        }

        public void Guess()
        {
            try
            {
                gn = int.Parse(textBox1.Text);
            }
            catch
            {
                MessageBox.Show("Please Enter a number in the text box between 1 - 10", "Game Warden");
            }

            bool win = false;
            bool wrong = false;
            if (textBox1.Text == "")
            {
            }
            else
            {
                if (gn >= 1 && gn <= 10)
                {
                    if (gn == rn)
                    {
                        win = true;
                        if (win == true)
                        {
                            AddWin();
                            if (MessageBox.Show("You have won! Would you like to play again ?", "Game Warden", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                rn = number.Next(1, 10);
                                label3.Text = "3";
                                textBox1.Clear();
                         
                            }
                            else
                            {
                                quit();
                            }
                        }
                        else
                        {
                            // Do nothing
                        }
                    }
                    else
                    {
                        wrong = true;
                    }



                }
                else
                {
                    MessageBox.Show("Please enter an integer from 1-10!", "Error!");
                    textBox1.Clear();
                }
            }
            if (wrong == true)
            {
                label3.Text = (int.Parse(label3.Text) - 1).ToString();
                if (label3.Text == "0")
                {
                    AddLose();
                    if (MessageBox.Show("You have lost! The randomized number was " + rn + ". Would you like to play again ?", "You lost!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        rn = number.Next(1, 10);
                        label3.Text = "3";
                        textBox1.Clear();
                    }
                    else
                    {
                        quit();
                    }
                }
                else
                {
                    if (gn > rn)
                    {
                        MessageBox.Show("Lower!", "Wrong!");
                        textBox1.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Higher!", "Wrong!");
                        textBox1.Clear();
                    }
                }
            }
            else
            {
                // Do nothing
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Guess();
        }

        private void quit()
        {
            if (MessageBox.Show("You have won " + wins.Text + " time(s) and lost " + loses.Text + " time(s) do you really wish to quit", "Thanks For Playing", MessageBoxButtons.OK) == DialogResult.OK)
            {
                if (Score() > GetHighScore())
                {
                    SetHighScore();
                    string score = GetHighScore().ToString();
                    MessageBox.Show("You have set the Highscore it is now: " + score + "", "Gamewarden");
                    this.Close()
                }
                else
                {
                    this.Close();
                }
            }
        }
     



        private void Form1_Load(object sender, EventArgs e)
        {

            rn = number.Next(1, 10);

        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                try
                {
                    gn = int.Parse(textBox1.Text);
                }
                catch
                {
                    MessageBox.Show("Please enter an integer from 1-10", "GameWarden");
                    textBox1.Clear();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("The High score is: " + GetHighScore().ToString(), "GameWarden");
        }
    }
}


Form1.Designer.cs
Code: [Select]
namespace GuessingGame
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.wins = new System.Windows.Forms.Label();
            this.loses = new System.Windows.Forms.Label();
            this.button2 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.Maroon;
            this.label1.Location = new System.Drawing.Point(0, 9);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(291, 20);
            this.label1.TabIndex = 0;
            this.label1.Text = "Guess A number between 1 and 10";
            //
            // button1
            //
            this.button1.BackColor = System.Drawing.Color.Maroon;
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button1.ForeColor = System.Drawing.Color.ForestGreen;
            this.button1.Location = new System.Drawing.Point(190, 33);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(90, 25);
            this.button1.TabIndex = 1;
            this.button1.Text = "Guess!";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.Maroon;
            this.label2.Location = new System.Drawing.Point(0, 37);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(90, 20);
            this.label2.TabIndex = 2;
            this.label2.Text = "Tries Left:";
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.Maroon;
            this.label3.Location = new System.Drawing.Point(88, 33);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(24, 25);
            this.label3.TabIndex = 3;
            this.label3.Text = "3";
            //
            // textBox1
            //
            this.textBox1.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
            this.textBox1.ForeColor = System.Drawing.Color.Maroon;
            this.textBox1.Location = new System.Drawing.Point(118, 36);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(66, 20);
            this.textBox1.TabIndex = 4;
            this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.Maroon;
            this.label4.Location = new System.Drawing.Point(12, 78);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(53, 20);
            this.label4.TabIndex = 5;
            this.label4.Text = "Wins:";
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.ForeColor = System.Drawing.Color.Maroon;
            this.label5.Location = new System.Drawing.Point(89, 78);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(62, 20);
            this.label5.TabIndex = 6;
            this.label5.Text = "Loses:";
            //
            // wins
            //
            this.wins.AutoSize = true;
            this.wins.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.wins.ForeColor = System.Drawing.Color.Maroon;
            this.wins.Location = new System.Drawing.Point(57, 74);
            this.wins.Name = "wins";
            this.wins.Size = new System.Drawing.Size(24, 25);
            this.wins.TabIndex = 7;
            this.wins.Text = "0";
            //
            // loses
            //
            this.loses.AutoSize = true;
            this.loses.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.loses.ForeColor = System.Drawing.Color.Maroon;
            this.loses.Location = new System.Drawing.Point(157, 74);
            this.loses.Name = "loses";
            this.loses.Size = new System.Drawing.Size(24, 25);
            this.loses.TabIndex = 8;
            this.loses.Text = "0";
            //
            // button2
            //
            this.button2.BackColor = System.Drawing.Color.Maroon;
            this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button2.ForeColor = System.Drawing.Color.ForestGreen;
            this.button2.Location = new System.Drawing.Point(190, 73);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(90, 25);
            this.button2.TabIndex = 9;
            this.button2.Text = "See High Score";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.SystemColors.InactiveCaption;
            this.ClientSize = new System.Drawing.Size(292, 108);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.loses);
            this.Controls.Add(this.wins);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label1);
            this.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Name = "Form1";
            this.Text = "Guessing Game";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label wins;
        private System.Windows.Forms.Label loses;
        private System.Windows.Forms.Button button2;
    }
}

Pages: [1]

Donate


* Search


* Recent Posts

I miss the chatbox by Shishka
[August 27, 2019, 11:52:39 pm]


Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]