coolcutter

Member
  • Content count

    14
  • Joined

  • Last visited

Community Reputation

122 Neutral

About coolcutter

  • Rank
    Member
  1. Beginning texturing

    How do i post a link?
  2. every time i try to run my code i get an error in application. I dont have the slightest clue as to whats going wrong. Any help would be greatly appreciated. my code in c#: // Beginning C# Game Programming // (C)2004 Ron Penton // Chapter 7 // Demo 3 - Colors and Alpha using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Direct3D = Microsoft.DirectX.Direct3D; using DirectSound = Microsoft.DirectX.DirectSound; using DirectInput = Microsoft.DirectX.DirectInput; namespace AdvancedFramework { // ------------------------------------------------------------------------ // The main Game class. // ------------------------------------------------------------------------ public class Game : Form { // -------------------------------------------------------------------- // static variables // -------------------------------------------------------------------- static string gametitle = "Demo 7.3 - Colors and Alpha"; static int screenwidth = 640; static int screenheight = 480; static bool windowed = true; static bool graphicslost = false; static Timer gametimer = null; static bool paused = false; // -------------------------------------------------------------------- // Devices // -------------------------------------------------------------------- Direct3D.Device graphics = null; DirectSound.Device sound = null; DirectInput.Device keyboard = null; DirectInput.Device mouse = null; DirectInput.Device gameinput = null; // -------------------------------------------------------------------- // Geometry // -------------------------------------------------------------------- Direct3D.CustomVertex.TransformedTextured[] vertexes = null; //Texture Direct3D.Texture texture = null; // -------------------------------------------------------------------- // Game constructor // -------------------------------------------------------------------- public Game() { ClientSize = new System.Drawing.Size( screenwidth, screenheight ); Text = gametitle; gametimer = new Timer(); } // -------------------------------------------------------------------- // Initialize the Direct3D Graphics subsystem // -------------------------------------------------------------------- public void InitializeGraphics() { // set up the parameters Direct3D.PresentParameters p = new Direct3D.PresentParameters(); p.SwapEffect = Direct3D.SwapEffect.Discard; if( windowed == true ) { p.Windowed = true; } else { // get the current display mode: Direct3D.Format current = Direct3D.Manager.Adapters[0].CurrentDisplayMode.Format; // set up a fullscreen display device p.Windowed = false; // fullscreen p.BackBufferCount = 1; // one back buffer p.BackBufferFormat = current; // use current format p.BackBufferWidth = screenwidth; p.BackBufferHeight = screenheight; } // create a new device: graphics = new Direct3D.Device( 0, Direct3D.DeviceType.Hardware, this, Direct3D.CreateFlags.SoftwareVertexProcessing, p ); // Setup the event handlers for the device graphics.DeviceLost += new EventHandler( this.InvalidateDeviceObjects ); graphics.DeviceReset += new EventHandler( this.RestoreDeviceObjects ); graphics.Disposing += new EventHandler( this.DeleteDeviceObjects ); graphics.DeviceResizing += new CancelEventHandler( this.EnvironmentResizing ); // set up various drawing options graphics.RenderState.CullMode = Direct3D.Cull.None; graphics.RenderState.AlphaBlendEnable = true; graphics.RenderState.AlphaBlendOperation = Direct3D.BlendOperation.Subtract; graphics.RenderState.DestinationBlend = Direct3D.Blend.InvSourceAlpha; graphics.RenderState.SourceBlend = Direct3D.Blend.SourceAlpha; } // -------------------------------------------------------------------- // Initialize the DirectSound subsystem // -------------------------------------------------------------------- public void InitializeSound() { // set up a device sound = new DirectSound.Device(); sound.SetCooperativeLevel( this, DirectSound.CooperativeLevel.Normal ); } // -------------------------------------------------------------------- // Initialize the DirectInput subsystem // -------------------------------------------------------------------- public void InitializeInput() { // set up the keyboard keyboard = new DirectInput.Device( DirectInput.SystemGuid.Keyboard ); keyboard.SetCooperativeLevel( this, DirectInput.CooperativeLevelFlags.Background | DirectInput.CooperativeLevelFlags.NonExclusive ); keyboard.Acquire(); // set up the mouse mouse = new DirectInput.Device( DirectInput.SystemGuid.Mouse ); mouse.SetCooperativeLevel( this, DirectInput.CooperativeLevelFlags.Background | DirectInput.CooperativeLevelFlags.NonExclusive ); mouse.Acquire(); } // -------------------------------------------------------------------- // Initialize the Geometry // -------------------------------------------------------------------- public void InitializeGeometry() { vertexes = new Direct3D.CustomVertex.TransformedTextured[4]; // triangle 1: // left vertex: vertexes[1].X = screenwidth / 4.0f; vertexes[1].Y = screenheight / 3.0f; vertexes[1].Z = 0.0f; vertexes[1].Tu = 1.0f; vertexes[1].Tv = 0.0f; // right vertex vertexes[3].X = screenwidth / 1.5f; vertexes[3].Y = screenheight / 3.0f; vertexes[3].Z = 0.0f; vertexes[3].Tu = 1.0f; vertexes[3].Tv = 1.0f; // bottom left vertexes[0].X = screenwidth / 4.0f; vertexes[0].Y = (screenheight / 3.0f) * 2.0f; vertexes[0].Z = 0.0f; vertexes[0].Tu = 0.0f; vertexes[0].Tv = 0.0f; // bottom right vertexes[2].X = screenwidth / 1.5f; vertexes[2].Y = (screenheight / 3.0f) * 2.0f; vertexes[2].Z = 0.0f; vertexes[2].Tu = 1.0f; vertexes[2].Tv = 1.0f; texture = Direct3D.TextureLoader.FromFile( graphics, "image.jpg", 0, 0, 0, 0, Direct3D.Format.Unknown, Direct3D.Pool.Managed, Direct3D.Filter.Linear, Direct3D.Filter.Linear, 0); } // -------------------------------------------------------------------- // Device Event Handlers // -------------------------------------------------------------------- protected virtual void InvalidateDeviceObjects( object sender, EventArgs e ) { } protected virtual void RestoreDeviceObjects( object sender, EventArgs e ) { } protected virtual void DeleteDeviceObjects( object sender, EventArgs e ) { } protected virtual void EnvironmentResizing( object sender, CancelEventArgs e ) { e.Cancel = true; } // -------------------------------------------------------------------- // Process one iteration of the game loop // -------------------------------------------------------------------- protected virtual void ProcessFrame() { // process the game only while it's not paused if( !paused ) { } else System.Threading.Thread.Sleep( 1 ); } // -------------------------------------------------------------------- // Render the current game screen // -------------------------------------------------------------------- protected virtual void Render() { if( graphics != null ) { // check to see if the device has been lost. If so, try to get // it back. if( graphicslost ) { try { graphics.TestCooperativeLevel(); } catch( Direct3D.DeviceLostException ) { // device cannot be reaquired yet, just return return; } catch( Direct3D.DeviceNotResetException ) { // device has not been reset, but it can be reaquired now graphics.Reset( graphics.PresentationParameters ); } graphicslost = false; } try { graphics.Clear( Direct3D.ClearFlags.Target, Color.White, 1.0f, 0 ); graphics.BeginScene(); graphics.SetTexture(0, texture); graphics.VertexFormat = Direct3D.CustomVertex.TransformedTextured.Format; graphics.DrawUserPrimitives(Microsoft.DirectX.Direct3D.PrimitiveType.TriangleStrip, 2, vertexes); graphics.EndScene(); graphics.Present(); } // device has been lost, and it cannot be re-initialized yet catch( Direct3D.DeviceLostException ) { graphicslost = true; } } } // -------------------------------------------------------------------- // Run the game // -------------------------------------------------------------------- public void Run() { // reset the game timer gametimer.Reset(); // loop while form is valid while( this.Created ) { // process one frame of the game ProcessFrame(); // render the current scene Render(); // handle all events Application.DoEvents(); } } // -------------------------------------------------------------------- // Handle windows events // -------------------------------------------------------------------- protected override void OnLostFocus( EventArgs e ) { base.OnLostFocus( e ); Paused = true; } protected override void OnKeyDown( KeyEventArgs e ) { base.OnKeyDown( e ); if( e.KeyCode == System.Windows.Forms.Keys.Escape ) { this.Close(); } if ( e.KeyCode == System.Windows.Forms.Keys.P ) { Paused = !Paused; } } // -------------------------------------------------------------------- // Property to pause/unpause the game, or get its pause state // -------------------------------------------------------------------- public bool Paused { get { return paused; } set { // pause the game if( value == true && paused == false ) { gametimer.Pause(); paused = true; } // unpause the game if( value == false && paused == true ) { gametimer.Unpause(); paused = false; } } } // -------------------------------------------------------------------- // Entry point of the program, creates a new game and runs it // -------------------------------------------------------------------- static void Main() { Game game; try { game = new Game(); game.InitializeGraphics(); game.InitializeSound(); game.InitializeInput(); game.InitializeGeometry(); game.Show(); game.Run(); } catch( Exception e ) { MessageBox.Show( "Error: " + e.Message ); } } } }
  3. Noooooooooo!!

    Anybody else feeling the complete boredom while xbox live is down?
  4. This is the code im working with right now but when i compile it gives "error creating direct3d device". any help would be useful. // Beginning Game Programming // Chapter 6 // Create_Surface program //header files to include #include <d3d9.h> #include <time.h> //application title #define APPTITLE "Create_Surface" //macros to read the keyboard asynchronously #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEY_UP(vk_code)((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) //screen resolution #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 //forward declarations LRESULT WINAPI WinProc(HWND,UINT,WPARAM,LPARAM); ATOM MyRegisterClass(HINSTANCE); int Game_Init(HWND); void Game_Run(HWND); void Game_End(HWND); //Direct3D objects LPDIRECT3D9 d3d = NULL; LPDIRECT3DDEVICE9 d3ddev = NULL; LPDIRECT3DSURFACE9 backbuffer = NULL; LPDIRECT3DSURFACE9 surface = NULL; //window event callback function LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_DESTROY: Game_End(hWnd); PostQuitMessage(0); return 0; } return DefWindowProc( hWnd, msg, wParam, lParam ); } //helper function to set up the window properties ATOM MyRegisterClass(HINSTANCE hInstance) { //create the window class structure WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); //fill the struct with info wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WinProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPTITLE; wc.hIconSm = NULL; //set up the window with the class info return RegisterClassEx(&wc); } //entry point for a Windows program int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // declare variables MSG msg; // register the class MyRegisterClass(hInstance); // initialize application //note--got rid of initinstance HWND hWnd; //create a new window hWnd = CreateWindow( APPTITLE, //window class APPTITLE, //title bar WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP, //window style CW_USEDEFAULT, //x position of window CW_USEDEFAULT, //y position of window SCREEN_WIDTH, //width of the window SCREEN_HEIGHT, //height of the window NULL, //parent window NULL, //menu hInstance, //application instance NULL); //window parameters //was there an error creating the window? if (!hWnd) return FALSE; //display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); //initialize the game if (!Game_Init(hWnd)) return 0; // main message loop int done = 0; while (!done) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { //look for quit message if (msg.message == WM_QUIT) done = 1; //decode and pass messages on to WndProc TranslateMessage(&msg); DispatchMessage(&msg); } else //process game loop (else prevents running after window is closed) Game_Run(hWnd); } return msg.wParam; } int Game_Init(HWND hwnd) { HRESULT result; //initialize Direct3D d3d = Direct3DCreate9(D3D_SDK_VERSION); if (d3d == NULL) { MessageBox(hwnd, "Error initializing Direct3D", "Error", MB_OK); return 0; } //set Direct3D presentation parameters D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = FALSE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.hDeviceWindow = hwnd; //create Direct3D device d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); if (d3d == NULL) { MessageBox(hwnd, "Error creating Direct3D device", "Error", MB_OK); return 0; } //set random number seed srand(time(NULL)); //clear the backbuffer to black d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); //create pointer to the back buffer d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer); //create surface result = d3ddev->CreateOffscreenPlainSurface( 100, //width of the surface 100, //height of the surface D3DFMT_X8R8G8B8, //surface format D3DPOOL_DEFAULT, //memory pool to use &surface, //pointer to the surface NULL); //reserved (always NULL) if (!result) return 1; //return okay return 1; } void Game_Run(HWND hwnd) { RECT rect; int r,g,b; //make sure the Direct3D device is valid if (d3ddev == NULL) return; //start rendering if (d3ddev->BeginScene()) { //fill the surface with random color r = rand() % 255; g = rand() % 255; b = rand() % 255; d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(r,g,b)); //copy the surface to the backbuffer rect.left = rand() % SCREEN_WIDTH/2; rect.right = rect.left + rand() % SCREEN_WIDTH/2; rect.top = rand() % SCREEN_HEIGHT; rect.bottom = rect.top + rand() % SCREEN_HEIGHT/2; d3ddev->StretchRect(surface, NULL, backbuffer, &rect, D3DTEXF_NONE); //stop rendering d3ddev->EndScene(); } //display the back buffer on the screen d3ddev->Present(NULL, NULL, NULL, NULL); //check for escape key (to exit program) if (KEY_DOWN(VK_ESCAPE)) PostMessage(hwnd, WM_DESTROY, 0, 0); } void Game_End(HWND hwnd) { //free the surface surface->Release(); //release the Direct3D device if (d3ddev != NULL) d3ddev->Release(); //release the Direct3D object if (d3d != NULL) d3d->Release(); }
  5. Possibly the best idea I ever had

    It seems like you push the rts people away with the rpg part and the rpg people away with the rts elements. If you could figure it out in another way that doesn't involve conventional elements from another genre than fine but now your just mixing the two.
  6. It seems as though when games are made they leave it up to the mail room to dub voice overs. Why do you think it's that hard to get a good voice over in a game? Check out this clip of resident evil for the ds and see for yourself exactly what i'm talking about. LOL http://www.youtube.com/watch?v=oiXpk_hn4q8
  7. You have the best response yet and the exact reasons. I agree totally. For the record on this post you notice that anyone who hasn't played gears always says it was marketing. When truthfully it wasn't marketed that well.
  8. Shakira or Beyonce

    Beyonce easy!!!
  9. Attack of The Clones

    It actually goes into production wise just like movies. If you know something about movies you know that many times in a mass off people it will be a group of extras dubbed over and multiplied to give the illusion of a large crowd. I'm pretty sure clones of the same enemy are to convey a sense of inhabitants and not individuals. I don't think the trend will stop because thats more than enough to convey to the player. It saves time, money, and helps you get your point across.
  10. Armorer skill: reparing armor

    If you want to keep your original design just make it so it only repairs when your moving.
  11. What elements do you think hurt Gears and what do you think super shot it into stardom?
  12. Would this be a possibility or not?

    I agree with him why directly relate it to jurassic park you dont do that part consumers do.
  13. Your favorite quest

    The best quest to me are when you get something you didn't think was on the game or something you completely forgot the game featured. Like on the Ocarina when you got Epona for the first time and you finally win and jump over the gate with her. WOOOOOOOOOOOOOOOO!! Good times.
  14. Your most depised game "features"

    Game: Ghost Recon Advanced Warfighter Feature: Online Multiplayer Comments: Thats absolutely ridiculous that when I play online with a friend we can only see our cross hairs and not the people.