rendered paste body# include <stdio.h>
# include <windows.h>
# include <ddraw.h>
# include <dsound.h>
# include "ddutil"
# include "dsutil"
# include "resource"
const int ironcore_nettobreite = 520; // Breite des Inneren des Haupfensters
const int ironcore_nettohoehe = 520; // Hoehe des Inneren des Hauptfensters
int ironcore_bruttobreite; // Breite des gesamten Haupfensters (incl. Rahmen)
int ironcore_bruttohoehe; // Hoehe des gesamten Haupfensters (incl. Rahmen)
HINSTANCE ironcore_instance; // Instanz der Ultris Applikation
HWND ironcore_window; // Das Hauptfenster von Ultris
HMENU ironcore_menu; // Das Menu von Ultris
// V2 Beginn
const int sound_001 = 0; // Sound fuer neues Spiel
const int sound_002 = 1; // Ersatzsound
const int anzahl_sounds = 3; // Anzahl Sounds
char *soundfiles[anzahl_sounds] =
{
"001.wav",
"002.wav",
};
class sounds
{
private:
CSoundManager smgr;
CSound *snd[anzahl_sounds];
public:
int on;
sounds();
int init( HWND wnd);
void play( int snr);
~sounds();
};
sounds::sounds()
{
int i;
for( i = 0; i < anzahl_sounds; i++)
snd[i] = 0;
on = 1;
}
int sounds::init( HWND wnd)
{
HRESULT ret;
int i;
ret = smgr.Initialize( wnd, DSSCL_PRIORITY, 2, 22050, 16);
if( ret < 0)
return ret;
for( i = 0; i < anzahl_sounds; i++)
{
ret = smgr.Create( snd+i, soundfiles[i]);
if( ret < 0)
return ret;
}
return S_OK;
}
sounds::~sounds()
{
int i;
for( i = 0; i < anzahl_sounds; i++)
{
if( snd[i])
delete snd[i];
}
}
void sounds::play( int i)
{
if( !on)
return;
if( snd[i]->IsSoundPlaying())
{
snd[i]->Stop();
snd[i]->Reset();
}
snd[i]->Play(0,0);
}
sounds ironcore_sounds;
// V2 Ende
/*
** ultris_windowhandler
*/
LRESULT CALLBACK ironcore_windowhandler( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_COMMAND:
switch( LOWORD( wParam))
{
case IDM_EXIT:
PostMessage( hWnd, WM_CLOSE, 0, 0);
return 0;
}
break;
case WM_GETMINMAXINFO:
((MINMAXINFO *)lParam)->ptMinTrackSize.x = ((MINMAXINFO *)lParam)->ptMaxTrackSize.x = ironcore_bruttobreite;
((MINMAXINFO *)lParam)->ptMinTrackSize.y = ((MINMAXINFO *)lParam)->ptMaxTrackSize.y = ironcore_bruttohoehe;
return 0;
case WM_DESTROY:
PostQuitMessage( 0);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
/*
** WinMain
*/
int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow)
{
MSG msg;
HACCEL acc;
WNDCLASSEX wcx;
ironcore_instance = hInst;
wcx.cbSize = sizeof( wcx);
wcx.lpszClassName = TEXT( "ultris");
wcx.lpfnWndProc = ironcore_windowhandler;
wcx.style = CS_VREDRAW | CS_HREDRAW;
wcx.hInstance = hInst;
wcx.hIcon = LoadIcon( hInst, MAKEINTRESOURCE( IDI_MAIN));
wcx.hIconSm = LoadIcon( hInst, MAKEINTRESOURCE( IDI_MAIN));
wcx.hCursor = LoadCursor( NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.lpszMenuName = MAKEINTRESOURCE( IDR_MENU);
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
if( !RegisterClassEx( &wcx))
return 0;
acc = LoadAccelerators( hInst, MAKEINTRESOURCE(IDR_ACCEL));
ironcore_bruttohoehe = ironcore_nettohoehe + 2*GetSystemMetrics( SM_CYSIZEFRAME)
+ GetSystemMetrics( SM_CYMENU)
+ GetSystemMetrics( SM_CYCAPTION);
ironcore_bruttobreite = ironcore_nettobreite + 2*GetSystemMetrics( SM_CXSIZEFRAME);
ironcore_window = CreateWindowEx( 0, TEXT( "Ultris"), TEXT( "Ironcore"), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
ironcore_bruttobreite, ironcore_bruttohoehe, NULL, NULL, hInst, NULL);
if( !ironcore_window)
return 0;
ironcore_menu = GetMenu( ironcore_window);
MoveWindow( ironcore_window, (GetSystemMetrics(SM_CXSCREEN)-ironcore_bruttobreite)/2,
(GetSystemMetrics(SM_CYSCREEN)-ironcore_bruttohoehe)/2,
ironcore_bruttobreite, ironcore_bruttohoehe, TRUE);
ShowWindow( ironcore_window, nCmdShow);
while( TRUE)
{
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE))
{
if( GetMessage( &msg, NULL, 0, 0 ) == 0)
return 0; // Message ist WM_QUIT
if( TranslateAccelerator( ironcore_window, acc, &msg) == 0)
{
TranslateMessage( &msg);
DispatchMessage( &msg);
}
}
else
{
// Hier koennen wir uns um das Spiel kuemmern
}
}
}
DIE HEADER DATEI:
#if !defined(AFX_DEMO_H__6F0BC346_A022_4D9B_B04C_63C781695029__INCLUDED_)
#define AFX_DEMO_H__6F0BC346_A022_4D9B_B04C_63C781695029__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"
#endif // !defined(AFX_DEMO_H__6F0BC346_A022_4D9B_B04C_63C781695029__INCLUDED_)