locked
Game SDK RRS feed

  • Question

  • Hi all,

    I wanted to ask you a few questions abaot game SDK:

    1. Might be really stupid one but ok - How do i know wich SDK am i using , i am asking that beacuse i got it uploaded on my college site and all i had to do is to download it and start working on my project. The main file is named Game SDK and visual studio files inside it are named 2DGameLanguage.

    2. After i downloaded it, i took some tours on youtube to find some tutorials. I've found this guy using the same SDK:

    -http://www.youtube.com/watch?v=70eswwFWNHY , so at the time i've decided to start on my own i got stuck wich brings me to next question.

    3.How do i load a sprite ?- i mean i have a method  loadSprite wich i've used here but it shows me the error: "Parameter is not valid", been trying to change the properties , saving in other formats (bmp now). As the tutorial on the link above says "drag the pictures on the project" , i've also done that. Then i decided to post it on one of my forums and i got an answer saying "Don't even attempt to make a game, the logic required is allot higher then what your brain can handle" , wich is verry encouraging. So i am asking you guys if you can help me, maybe i don't know much abaot SDKs but i am willing to learn.

    Thank you.

    Sunday, January 12, 2014 9:47 AM

Answers

All replies

  • Hi Somebody00,

    This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 1:56 AM
  • Might have been these ones.

    http://msdn.microsoft.com/en-us/library/windows/apps/dn194515.aspx

    http://msdn.microsoft.com/library/windows/apps/hh452744.aspx

    I'd ask them over here about directx programming.

    http://social.msdn.microsoft.com/Forums/windowsapps/en-us/home?category=windowsapps

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    • Proposed as answer by Just Karl Monday, January 13, 2014 5:45 PM
    • Marked as answer by Just Karl Monday, January 20, 2014 7:37 PM
    Monday, January 13, 2014 2:23 AM
  • well it's actually all made in c#... i don't know why can't i load that sprite :/
    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.Media;
    using System.IO;
    using System.Threading;
    
    namespace _2dGameLanguage
    {
        public partial class BGL : Form
        {
            //Instance Variables
            #region
            double lastTime, thisTime, diff;
            Sprite[] sprites = new Sprite[1000];
            SoundPlayer[] sounds = new SoundPlayer[1000];
            TextReader[] readFiles = new StreamReader[1000];
            TextWriter[] writeFiles = new StreamWriter[1000];
            int spriteCount = 0, soundCount = 0;
            string inkey;
            int mouseKey, mouseXp, mouseYp;
            Rectangle Collision;
            bool showSync = false;
            int loopcount;
            DateTime dt = new DateTime();
            String time;
            #endregion
    
            //Structs
            #region 
            public struct Sprite
            {
                public string image;
                public Bitmap bmp;
                public int x, y, width, height;
                public bool show;
    
                public Sprite(string images, int p1, int p2)
                {
                    bmp = new Bitmap(images);
                    image = images;
                    x = p1;
                    y = p2;
                    width = bmp.Width;
                    height = bmp.Height;
                    show = true;
                }
    
                public Sprite(string images, int p1, int p2, int w, int h)
                {
                    bmp = new Bitmap(images);
                    image = images;
                    x = p1;
                    y = p2;
                    width = w;
                    height = h;
                    show = true;
                }
            }
    
            #endregion
    
            public BGL()
            {
                InitializeComponent();
            }
    
            public void Init()
            {
                if (dt == null) time = dt.TimeOfDay.ToString();
                loopcount++;
                //Load resources and level here
                loadSprite("ball.bmp",1);
    
    
            }
    
            private void Update(object sender, EventArgs e)
            {
                    this.Refresh();
    
    
    
    
    
    
    
            }
    
            // Start of Game Methods
    
            #region
    
            //This is the beginning of the setter methods
    
            private void startTimer(object sender, EventArgs e)
            {
                timer1.Start();
                timer2.Start();
                Init();
            }
    
            public void showSyncRate(bool val)
            {
                showSync = val;
                if (val == true) syncRate.Show();
                if (val == false) syncRate.Hide();
            }
    
    
            public void updateSyncRate()
            {
                if (showSync == true)
                {
                    thisTime = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
                    diff = thisTime - lastTime;
                    lastTime = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
    
                    double fr = (1000 / diff) / 1000;
    
                    int fr2 = Convert.ToInt32(fr);
    
                    syncRate.Text = fr2.ToString();
                }
                  
            }
    
            public void setTitle(string title)
            {
                this.Text = title;
            }
    
            public void setBackgroundColour(int r, int g, int b)
            {
                this.BackColor = Color.FromArgb(r, g, b);
            }
    
            public void setBackgroundColour(Color col)
            {
                this.BackColor = col;
            }
    
            public void setBackgroundImage(string backgroundImage)
            {
                this.BackgroundImage = new Bitmap(backgroundImage);
            }
    
            public void setBackgroundImageLayout(string layout)
            {
                if (layout.ToLower() == "none") this.BackgroundImageLayout = ImageLayout.None;
                if (layout.ToLower() == "tile") this.BackgroundImageLayout = ImageLayout.Tile;
                if (layout.ToLower() == "stretch") this.BackgroundImageLayout = ImageLayout.Stretch;
                if (layout.ToLower() == "center") this.BackgroundImageLayout = ImageLayout.Center;
                if (layout.ToLower() == "zoom") this.BackgroundImageLayout = ImageLayout.Zoom;
            }
            
            private void updateFrameRate(object sender, EventArgs e)
            {
                updateSyncRate();
            }
    
            public void loadSprite(string file, int spriteNum)
            {
                spriteCount++;
                sprites[spriteNum] = new Sprite(file, 0, 0);
            }
    
            public void loadSprite(string file, int spriteNum, int x, int y)
            {
                spriteCount++;
                sprites[spriteNum] = new Sprite(file, x, y);
            }
    
            public void loadSprite(string file, int spriteNum, int x, int y, int w, int h)
            {
                spriteCount++;
                sprites[spriteNum] = new Sprite(file, x, y, w, h);
            }
    
            public void rotateSprite(int spriteNum, int angle)
            {
                if (angle == 90)
                    sprites[spriteNum].bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
                if (angle == 180)
                    sprites[spriteNum].bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
                if (angle == 270)
                    sprites[spriteNum].bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
            }
    
            public void scaleSprite(int spriteNum, int scale)
            {
                float sx = float.Parse(sprites[spriteNum].width.ToString());
                float sy = float.Parse(sprites[spriteNum].height.ToString());
                float nsx = ((sx / 100) * scale); 
                float nsy = ((sy / 100) * scale);
    
                sprites[spriteNum].width = Convert.ToInt32(nsx);
                sprites[spriteNum].height = Convert.ToInt32(nsy);
            }
    
            public void moveSprite(int spriteNum, int x, int y)
            {
                sprites[spriteNum].x = x;
                sprites[spriteNum].y = y;
            }
    
            public void setImageColorKey(int spriteNum, int r, int g, int b)
            {
                sprites[spriteNum].bmp.MakeTransparent(Color.FromArgb(r, g, b));
            }
    
            public void setImageColorKey(int spriteNum, Color col)
            {
                sprites[spriteNum].bmp.MakeTransparent(col);
            }
    
            public void setSpriteVisible(int spriteNum, bool ans)
            {
                sprites[spriteNum].show = ans;
            }
    
            public void hideSprite(int spriteNum)
            {
                sprites[spriteNum].show = false;
            }
    
    
            public void flipSprite(int spriteNum, string fliptype)
            {
                if(fliptype.ToLower() == "none")
                sprites[spriteNum].bmp.RotateFlip(RotateFlipType.RotateNoneFlipNone);
    
                if (fliptype.ToLower() == "horizontal")
                sprites[spriteNum].bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
    
                if (fliptype.ToLower() == "horizontalvertical")
                sprites[spriteNum].bmp.RotateFlip(RotateFlipType.RotateNoneFlipXY);
    
                if (fliptype.ToLower() == "vertical")
                sprites[spriteNum].bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
            }
    
            public void changeSpriteImage(int spriteNum, string file)
            {
                sprites[spriteNum] = new Sprite(file, sprites[spriteNum].x, sprites[spriteNum].y);
            }
    
            public void loadSound(int soundNum, string file)
            {
                soundCount++;
                sounds[soundNum] = new SoundPlayer(file);
            }
    
            public void playSound(int soundNum)
            {
                sounds[soundNum].Play();
            }
    
            public void loopSound(int soundNum)
            {
                sounds[soundNum].PlayLooping();
            }
    
            public void stopSound(int soundNum)
            {
                sounds[soundNum].Stop();
            }
    
            public void openFileToRead(string fileName, int fileNum)
            {
                readFiles[fileNum] = new StreamReader(fileName);
            }
    
            public void closeFileToRead(int fileNum)
            {
                readFiles[fileNum].Close();
            }
    
            public void openFileToWrite(string fileName, int fileNum)
            {
                writeFiles[fileNum] = new StreamWriter(fileName);
            }
    
            public void closeFileToWrite(int fileNum)
            {
                writeFiles[fileNum].Close();
            }
    
            public void writeLine(int fileNum, string line)
            {
                writeFiles[fileNum].WriteLine(line);
            }
    
            public void hideMouse()
            {
                Cursor.Hide();
            }
    
            public void showMouse()
            {
                Cursor.Show();
            }
    
    
    
            //This is the beginning of the getter methods
    
            public bool spriteExist(int spriteNum)
            {
                if (sprites[spriteNum].bmp != null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
    
            public int spriteX(int spriteNum)
            {
                return sprites[spriteNum].x;
            }
    
            public int spriteY(int spriteNum)
            {
                return sprites[spriteNum].y;
            }
    
            public int spriteWidth(int spriteNum)
            {
                return sprites[spriteNum].width;
            }
    
            public int spriteHeight(int spriteNum)
            {
                return sprites[spriteNum].height;
            }
    
            public bool spriteVisible(int spriteNum)
            {
                return sprites[spriteNum].show;
            }
    
            public string spriteImage(int spriteNum)
            {
                return sprites[spriteNum].bmp.ToString();
            }
    
            public bool isKeyPressed(string key)
            {
                if (inkey == key)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
    
            public bool isKeyPressed(Keys key)
            {
                if (inkey == key.ToString())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
    
            public bool spriteCollision(int spriteNum1, int spriteNum2)
            {
                Rectangle sp1 = new Rectangle(sprites[spriteNum1].x, sprites[spriteNum1].y, sprites[spriteNum1].width, sprites[spriteNum1].height);
                Rectangle sp2 = new Rectangle(sprites[spriteNum2].x, sprites[spriteNum2].y, sprites[spriteNum2].width, sprites[spriteNum2].height);
                Collision = Rectangle.Intersect(sp1, sp2);
    
                if (!Collision.IsEmpty)
                {
                    return true;
                }
                else
                {
                    return false;
                }
    
            }
    
            public string readLine(int fileNum)
            {
                return readFiles[fileNum].ReadLine();
            }
    
            public string readFile(int fileNum)
            {
                return readFiles[fileNum].ReadToEnd();
            }
    
            public bool isMousePressed() {
                if (mouseKey == 1) return true;
                else return false;
            }
    
            public int mouseX()
            {
                return mouseXp;
            }
    
            public int mouseY()
            {
                return mouseYp;
            }
    
            #endregion
    
    
            //Game Update and Input
            #region
            private void Draw(object sender, PaintEventArgs e)
            {
                Graphics g = e.Graphics;
    
                foreach (Sprite sprite in sprites)
                {
                    if (sprite.bmp != null && sprite.show == true)
                        g.DrawImage(sprite.bmp, new Rectangle(sprite.x, sprite.y, sprite.width, sprite.height));
                }
            }
    
            private void keyDown(object sender, KeyEventArgs e)
            {
                inkey = e.KeyCode.ToString();
            }
    
            private void keyUp(object sender, KeyEventArgs e)
            {
                inkey = "";
            }
    
            private void mouseClicked(object sender, MouseEventArgs e)
            {
                mouseKey = 1;
            }
    
            private void mouseDown(object sender, MouseEventArgs e)
            {
                mouseKey = 1;
            }
    
            private void mouseUp(object sender, MouseEventArgs e)
            {
                mouseKey = 0;
            }
    
            private void mouseMove(object sender, MouseEventArgs e)
            {
                mouseXp = e.X;
                mouseYp = e.Y;
            }
    
    #endregion
    
        }
    }
    

    Monday, January 13, 2014 9:56 AM