Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# coding help/XNA game 4.0
New Posts  All Forums:Forum Nav:

C# coding help/XNA game 4.0 - Page 2

post #11 of 22
Quote:
Originally Posted by Core2uu View Post
Definitely. Game programming can often involve some very complex programming concepts and at first-glance, everything can just fly over your head. Writing little console programs in those "regular" classes may not be as exciting as creating a game, but they go a long way in giving you a solid foundation onto which you can build your skills towards game programming.

Oh, and game programming also involves a lot of math, depending on what you're doing, so be aware of that.
Polymorphism, inheritance, OOP (the advanced parts, OOP is easy enough in itself), typecasting, pointers and the fun goes on . At least c# gets rid of the issues with cryptic messages from the compiler
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #12 of 22
Declarations:
Code:
Texture2D background[][];
Texture2D sprite;
Vector2 position;
Rectangle viewportRect;
int m, n;
Initialization:
Code:
graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;
graphics.IsFullScreen = false;
graphics.ApplyChanges();
Window.Title = "Your Title"

viewportRect = new Rectangle(0, 0,
graphics.GraphicsDevice.Viewport.Width,
graphics.GraphicsDevice.Viewport.Height);

position = new Vector2 (graphics.GraphicsDevice.Viewport.Width/2,
graphics.GraphicsDevice.Viewport.Height/2);
m=0;
n=0;
Load:
Code:

sprite = Content.Load<Texture2D>("path to image");

I am not sure about loading images into matrix
Update:
Code:
if (position.X < 0 && m > 0)
{
m -=1;
position.X = 1024
}
if (position.X > 1024 && m < 3)
{
m +=1;
position.X = 0
}
if (position.Y < 0 && n > 0)
{
n -=1;
position.Y = 768;
}
if (position.Y > 768 && n < 3)
{
n +=1;
position.Y = 0;
}
Draw:
Code:
spriteBatch.Begin();
//Draw background
spriteBatch.Draw(background[m][n], viewportRect, Color.White);
//Draw sprite
spriteBatch.Draw(sprite, position, Color.White);
spriteBatch.End();
I am also a novice, but here's what I think
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
post #13 of 22
^Nice job, and I'm not sure about loading images themselves into a matrix, but I believe you can point to the image objects themselves using pointers? I don't know, I'm a novice programmer too.
Edited by Core2uu - 11/3/11 at 1:20am
myTX Prodigy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570 ASUS P8H77-I XFX Radeon HD 7870 Double D GSKILL 8GB DDR3-1600 
Hard DriveHard DriveHard DriveHard Drive
Samsung SSD 840 250GB Crucial m4 128GB Seagate Barracuda 500GB Western Digital Black 1TB 
Optical DriveOSMonitorKeyboard
ASUS CD/DVD RW 24X Windows 8 Pro x64 ASUS VE247 24" Microsoft Sidewinder X4 
PowerCaseMouseMouse Pad
Corsair TX550M Bitfenix Prodigy Steelseries Kinzu Gigabyte Ghost 
  hide details  
Reply
myTX Prodigy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570 ASUS P8H77-I XFX Radeon HD 7870 Double D GSKILL 8GB DDR3-1600 
Hard DriveHard DriveHard DriveHard Drive
Samsung SSD 840 250GB Crucial m4 128GB Seagate Barracuda 500GB Western Digital Black 1TB 
Optical DriveOSMonitorKeyboard
ASUS CD/DVD RW 24X Windows 8 Pro x64 ASUS VE247 24" Microsoft Sidewinder X4 
PowerCaseMouseMouse Pad
Corsair TX550M Bitfenix Prodigy Steelseries Kinzu Gigabyte Ghost 
  hide details  
Reply
post #14 of 22
Quote:
Originally Posted by Core2uu View Post
^Nice job, and I'm not sure about loading images themselves into a matrix, but I believe you can point to the image objects themselves using pointers? I don't know, I'm a novice programmer to.
I've only read half the syntax of C, and I can say that I cannot remember any of that. All I can remember is something to do with the * and & before a variable.
I would actually leave off the matrix, and go with something along the lines of this:

0 1 2
3 4 5
6 7 8

and then up/down +/- 3, left/right +/- 1.
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
post #15 of 22
Quote:
Originally Posted by guiJY View Post
I've only read half the syntax of C, and I can say that I cannot remember any of that. All I can remember is something to do with the * and & before a variable.
I would actually leave off the matrix, and go with something along the lines of this:

0 1 2
3 4 5
6 7 8

and then up/down +/- 3, left/right +/- 1.
* is a pointer, & is a reference. Might want to go and read up on them, they can be useful (and dangerous - memory leaks anyone? )
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #16 of 22
Quote:
Originally Posted by FiX View Post
* is a pointer, & is a reference. Might want to go and read up on them, they can be useful (and dangerous - memory leaks anyone? )
Yes, this. Are you implying BF3 screwed up their pointers?
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
post #17 of 22
Quote:
Originally Posted by guiJY View Post
Yes, this. Are you implying BF3 screwed up their pointers?
Not necessarily They might have not been managing the memory as well as they could, but it wasnt too bad for the amount of stuff loaded in the game.
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #18 of 22
It's more likely that they didn't implement garbage collection properly. Allocating memory is fine, as long as you're doing it within reason and releasing it back to the OS when you're finished.
myTX Prodigy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570 ASUS P8H77-I XFX Radeon HD 7870 Double D GSKILL 8GB DDR3-1600 
Hard DriveHard DriveHard DriveHard Drive
Samsung SSD 840 250GB Crucial m4 128GB Seagate Barracuda 500GB Western Digital Black 1TB 
Optical DriveOSMonitorKeyboard
ASUS CD/DVD RW 24X Windows 8 Pro x64 ASUS VE247 24" Microsoft Sidewinder X4 
PowerCaseMouseMouse Pad
Corsair TX550M Bitfenix Prodigy Steelseries Kinzu Gigabyte Ghost 
  hide details  
Reply
myTX Prodigy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-3570 ASUS P8H77-I XFX Radeon HD 7870 Double D GSKILL 8GB DDR3-1600 
Hard DriveHard DriveHard DriveHard Drive
Samsung SSD 840 250GB Crucial m4 128GB Seagate Barracuda 500GB Western Digital Black 1TB 
Optical DriveOSMonitorKeyboard
ASUS CD/DVD RW 24X Windows 8 Pro x64 ASUS VE247 24" Microsoft Sidewinder X4 
PowerCaseMouseMouse Pad
Corsair TX550M Bitfenix Prodigy Steelseries Kinzu Gigabyte Ghost 
  hide details  
Reply
post #19 of 22
Quote:
Originally Posted by Core2uu View Post
It's more likely that they didn't implement garbage collection properly. Allocating memory is fine, as long as you're doing it within reason and releasing it back to the OS when you're finished.
C++ means managing it yourself.. oh the fun I really need to get back to my game engine lol.. Havent done anything on it in a week.. Need to get map loading finished
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #20 of 22
Quote:
Originally Posted by FiX View Post
C++ means managing it yourself.. oh the fun I really need to get back to my game engine lol.. Havent done anything on it in a week.. Need to get map loading finished
Your own game engine? Wow, so pro!
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
Sig Rig
(9 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASUS P8Z68-V PRO Geforce GTX 560 Ti G.Skills Ripjaws X 
Hard DriveCoolingMonitorPower
OCZ Vertex 3 120GB MAX IOPS Thermalright Silver Arrow Dell U2412HM Corsair AX850 
Case
CM Storm Enforcer 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# coding help/XNA game 4.0