Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Official] Eclipse.NET


JeffSventora
 Share

Recommended Posts

  • 3 weeks later...
  • Replies 337
  • Created
  • Last Reply

Top Posters In This Topic

Okay guys, I've been literally BUSTING my ass with this. I promised some huge updates and so now here they are.

To start off, I ditched XNA. I make games, and I do my best to make GREAT games. XNA was just too limited for my taste so I migrated to C++ using the Win32 API. Not only does this offer me MUCH better performance but it also grants me FULL control over the program. So, lets begin…

**Custom Win32 Window Wrapper**
I programmed a dynamic Window Wrapper that manages and creates Windows for the programmer to use throughout the program. In VB6 it's as simple as right clicking and adding a new form, in C++ it's a bit… I mean, a lot different.

**Direct2D/COM Implementation**
Remember DirectDraw? of course you do. Anyone using a DX7 based Engine uses it for 2D rendering. Well Microsoft has actually created a newer alternative to this API called Direct2D and DirectWrite which are only available for Windows Vista SP2 and Windows 7\. This magnificent  API is VERY fun and easy to work with.

Well, enough chit chat. Here is what you were looking for, SOURCE CODES!!
You are about to witness a lot of code, beware, all it does is open windows and prepare D2D. Damn that's alot for something so simple right? Haha

**StadInc.h (Includes all necessary files)**
```
// Include Files
#include
#include
#include
#include
#include
#include

// Direct2D
#include // Include the Direct2D API.
#include // Include the DirectWrite API.

// Include Globals
#include "Globals.h"

```
**Window Manager Class**

> **AppWindow.h**
> ```
> #pragma once
>
> #include "StdInc.h"
>
> struct AppWindow;
> #include "WindowPane.h"
>
> struct AppWindow
> {
> // Data Members
> WindowPane* Parent;
> int ID;
> std::wstring Caption;
> HWND hWnd;
>
> // Constructor
> AppWindow(WindowPane*, LPCWSTR, LPCWSTR, LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM), int, int, int);
>
> // Methods
> void Show(void);
> void Hide(void);
> void Destroy(void);
> };
> ```
> **AppWindow.cpp**
> ```
> #include "AppWindow.h"
>
> // Constructor
> AppWindow::AppWindow(WindowPane* nParent, LPCWSTR ClassName, LPCWSTR szCaption, LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM), int Width, int Height, int Style)
> {
> Parent = nParent;
> Caption = szCaption;
>
> const int ScreenX = (GetSystemMetrics(SM_CXSCREEN) - Width) >> 1;
> const int ScreenY = (GetSystemMetrics(SM_CYSCREEN) - Height) >> 1;
>
> // Register a Window Class
> WNDCLASSEX wcex = {};
> wcex.cbSize = sizeof(wcex);
> wcex.cbClsExtra = 0;
> wcex.cbWndExtra = 0;
> wcex.style = CS_HREDRAW | CS_VREDRAW;
>
> wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
> wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
> wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
> wcex.hInstance = Parent->GetHIN();
>
> wcex.lpszMenuName = NULL;
> wcex.lpszClassName = ClassName; // The name that identifies the Window class.
> wcex.lpfnWndProc = WndProc; // Name of the Message Handler Function
>
> RegisterClassEx(&wcex);
>
> // Correct Window Dimensions
> RECT RC = {0, 0, Width, Height};
> AdjustWindowRect(&RC, Style, TRUE);
>
> // Create the Main Window
> hWnd = CreateWindow(wcex.lpszClassName, szCaption, Style, ScreenX, ScreenY, RC.right - RC.left, RC.bottom - RC.top, HWND_DESKTOP, NULL, Parent->GetHIN(), NULL);
>
> // Error Check Window Handle
> if(!hWnd)
> {
> // Inform user about the error.
> MessageBox(HWND_DESKTOP, _T("Failed to create the Main Window!"), _T("Error!"), MB_OK | MB_ICONERROR);
> }
> }
>
> void AppWindow::Show(void)
> {
> // Display the Main Window
> ShowWindow(hWnd, SW_NORMAL);
> UpdateWindow(hWnd);
> }
>
> void AppWindow::Hide(void)
> {
> ShowWindow(hWnd, SW_HIDE);
> UpdateWindow(hWnd);
> }
>
> void AppWindow::Destroy(void)
> {
> DestroyWindow(hWnd);
> }
> ```
> **WindowPane.h**
> ```
> #pragma once
>
> #include "StdInc.h"
>
> class WindowPane;
> #include "AppWindow.h"
>
> class WindowPane
> {
> // Data Members
> HINSTANCE _hInstance;
> HINSTANCE _hPrevious;
> LPTSTR _lpCmd;
> int _CmdShow;
> int _NumWindows;
>
> std::vector Windows;
>
> bool IsRunning;
>
> public:
> // Constructor
> WindowPane(HINSTANCE&, HINSTANCE&, LPTSTR, int);
>
> // Accessors
> HINSTANCE& GetHIN(void) { return _hInstance; }
> HINSTANCE& GetHPR(void) { return _hPrevious; }
> LPTSTR GetLPCMD(void) { return _lpCmd; }
> int GetCMDSHOW(void) { return _CmdShow; }
>
> // Methods
> void AddWindow(LPCWSTR ClassName, LPCWSTR WinTitle, int, int, int, LRESULT (CALLBACK *WndProc)(HWND, UINT, WPARAM, LPARAM));
> void RemoveWindow(int);
> void ShowWindow(int);
> void Run(void);
> void ShutDown(void);
>
> // Safety!
> ~WindowPane(void);
> };

> ```
> **WindowPane.cpp**
> ```
> #include "WindowPane.h"
>
> bool VectorSort (int i,int j) { return (iID = _NumWindows++;
>
> if(!IsRunning)
> {
> IsRunning = true;
> ShowWindow(0);
> Run();
> }
> }
>
> void WindowPane::ShowWindow(int Index)
> {
> Windows[Index]->Show();
> }
>
> void WindowPane::RemoveWindow(int Index)
> {
> Windows[Index]->Destroy();
> Windows.erase(Windows.begin() + Index);
> --_NumWindows;
> }
>
> void WindowPane::Run(void)
> {
> MSG msg = {};
>
> while(IsRunning)
> {
> if(PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
> {
> TranslateMessage(&msg);
> DispatchMessage(&msg);
> }
> // else
> //    GameLoop();
> }
> }
>
> void WindowPane::ShutDown(void)
> {
> for(unsigned int i = 0; i < Windows.size(); ++i)
> Windows[i]->Destroy();
>
> IsRunning = false;
> }
>
> // Safety!
> WindowPane::~WindowPane(void)
> {
> ShutDown();
> }
>
> [b]D2D Wrapper (Written by me)[/b]
> [quote][b]D2DManager.h[/b]
> [code]#pragma once
>
> #include "StdInc.h"
>
> #pragma comment(lib, "d2d1.lib") // Connect to the Direct2D Import Library.
> #pragma comment(lib, "dwrite.lib") // Connect to the DirectWrite Import Library.
>
> // Safely release all components
> template void SafeRelease(Type**);
>
> // Error Checking
> bool Error(LPCWSTR, LPCWSTR);
>
> // Color Macro
> #define D2DColor(clr) D2D1::ColorF(D2D1::ColorF::clr)
>
> struct D2D
> {
> // Direct2D Interface
> ID2D1Factory* D2DFactory;
> ID2D1HwndRenderTarget* Device;
>
> // DirectWrite Interface
> IDWriteFactory* DWFactory;
> IDWriteTextFormat* TextFormat;
>
> // Brushes
> ID2D1SolidColorBrush* SolBrush;
>
> // Constructor
> D2D(HWND);
>
> // Destructor (Play it safe!)
> ~D2D(void);
>
> // Direct2D Methods
> bool D2DInit(HWND);
> void D2DRelease(void);
> void SetCol(const D2D1_COLOR_F&, int Opacity = 1.0f);
> };
>
> // Constructor
> D2D::D2D(HWND hWnd)
> {
> D2DInit(hWnd);
> }
>
> // Destructor (Play it safe!)
> D2D::~D2D(void)
> {
> D2DRelease();
> }
>
> bool D2D::D2DInit(HWND hWnd)
> {
> HRESULT Check; // Used for error checking furing Init.
> RECT ClientRect; // Holds data corresponding to the clients dimensions
> GetClientRect(hWnd, &ClientRect);
> D2D1_SIZE_U ClientSize = D2D1::SizeU(ClientRect.right, ClientRect.bottom);
>
> // Init D2D Factory
> Check = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &D2DFactory);
> if(FAILED(Check))
> return Error(_T("Failed to Intialize the D2D Factory!"), _T("D2D Error!"));
>
> // Set up the Render Device (Render Target)
> Check = D2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties(hWnd, ClientSize), &Device);
> if(FAILED(Check))
> return Error(_T("Failed to initialize the Render Device!"), _T("D2D Error!"));
>
> // Set the Render Device's DPI Settings
> Device->SetDpi(96.0f, 96.0f);
>
> // Initialize the DirectWrite Factory
> Check = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&DWFactory);
> if(FAILED(Check))
> return Error(_T("Failed to initialize the DirectWrite Factory!"), _T("D2D Error!"));
>
> // Initialize the Text Format
> Check = DWFactory->CreateTextFormat(_T("Veranda"), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 14, _T("en-us"), &TextFormat);
> if(FAILED(Check))
> return Error(_T("Failed to initialize the default Text Format!"), _T("D2D Error!"));
>
> // Initialize the Main Solid Color Brush
> Check = Device->CreateSolidColorBrush(D2DColor(Black), &SolBrush);
> if(FAILED(Check))
> return Error(_T("Failed to initialize the main Brush!"), _T("D2D Error!"));
>
> // Everything was okay!
> return true;
> }
>
> void D2D::D2DRelease(void)
> {
> // Release in the reverse order in which you initialized
> SafeRelease(&SolBrush);
> SafeRelease(&TextFormat);
> SafeRelease(&DWFactory);
> SafeRelease(&Device);
> SafeRelease(&D2DFactory);
> }
>
> void D2D::SetCol(const D2D1_COLOR_F& NewColor, int Opacity)
> {
> SolBrush->SetColor(NewColor);
> SolBrush->SetOpacity(Opacity);
> }
>
> template void SafeRelease(Type** ToRelease)
> {
> if(ToRelease)
> {
> (*ToRelease)->Release();
> (*ToRelease) = nullptr;
> }
> }
>
> bool Error(LPCWSTR Body, LPCWSTR Title)
> {
> MessageBox(HWND_DESKTOP, Body, Title, MB_OK | MB_ICONERROR);
> return false; // Always return false!
> }[/code][/quote]
> [b]Globals.h (Global Namespace) preparing for Future use.[/b]
> [code]#pragma once
>
> namespace Globals
> {
> // Window Constants
> const int FRM_MAIN = 0X0000;
>
> // Game Constants
> const int MAX_PLAYERS = 1000;
> }[/code]
> [b]FrmMain.h (Handles the drawing for FrmMain)[/b]
> [code]#pragma once
>
> #include "StdInc.h"
> #include "D2DManager.h"
>
> D2D1_COLOR_F ScreenBG = D2DColor(CornflowerBlue);
>
> void OnPaint(HWND, D2D*&);
>
> void OnPaint(HWND hWnd, D2D*& Manager)
> {
> // Begin Drawing
> Manager->Device->BeginDraw();
> Manager->Device->Clear(ScreenBG);
>
> /********** DRAWING LOGIC HERE **********/
>
>
>
> /****************************************/
>
> // End Drawing
> HRESULT CheckHR = Manager->Device->EndDraw();
> if(CheckHR == D2DERR_RECREATE_TARGET)
> {
> Manager->D2DRelease();
> Manager->D2DInit(hWnd);
> }
> }[/code]
> [b]WinMain.cpp (Entry point for the program, also inits everything)[/b]
> [code]#include "StdInc.h"
> #include "WindowPane.h"
> #include "D2DManager.h"
> #include "FrmMain.h"
>
> WindowPane* Manager;
> D2D* GFXManager;
>
> LRESULT CALLBACK FRM_MAIN_WndProc(HWND, UINT, WPARAM, LPARAM);
>
> INT CALLBACK _tWinMain(HINSTANCE hIn, HINSTANCE hPrev, LPTSTR lpCMD, int CMDShow)
> {
> // Initialize the COM Library.
> CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
>
> Manager = new WindowPane(hIn, hPrev, lpCMD, CMDShow);
>
> Manager->AddWindow(_T("Test Window"), _T("Testing!"), 800, 480, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, FRM_MAIN_WndProc);
>
> delete Manager;
>
> // Uninitialize the COM Library.
> CoUninitialize();
>
> return 0;
> }
>
> LRESULT CALLBACK FRM_MAIN_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
> {
> switch(uMsg)
> {
> case WM_CREATE:
> GFXManager = new D2D(hWnd);
> break;
>
> case WM_PAINT:
> OnPaint(hWnd, GFXManager);
> break;
>
> case WM_CLOSE:
> Manager->RemoveWindow(Globals::FRM_MAIN);
> break;
>
> case WM_DESTROY:
> Manager->ShutDown();
> delete GFXManager;
> PostQuitMessage(Globals::FRM_MAIN);
> break;
>
> case WM_LBUTTONDOWN:
> break;
>
> default:
> return DefWindowProc(hWnd, uMsg, wParam, lParam);
> }
>
> return 0;
> }[/code]
> [b]After completing the Windows Direct2D client, I WILL be making one with SDL, I followed Stephan's advice and did some tutorials.[/b][/i]

> ```
Link to comment
Share on other sites

**Minor Update**
Converted to a more real-time approach to the game client. In other words, I incorporated some simple Multi-threading techniques to provide a more flexible design. I also added full screen support that can easily be toggled.

Right now I'm working on creating some custom controls for the GUI components. Stay tuned, I would like to have a very basic client demo soon.
Link to comment
Share on other sites

Oh, this is nothing against you 'Jsventor', but after posting my similar project up it was decline because it was a 'game engine', bullshit - I think so? Personally, I think this engine is a great idea; by the way! But once again, I cannot stress enough -why- my project was declined. Simply put, it 'violated the rules', but this topic was exempt. Anyone here support me?
Link to comment
Share on other sites

@Vaughan:

> Oh, this is nothing against you 'Jsventor', but after posting my similar project up it was decline because it was a 'game engine', bullshit - I think so? Personally, I think this engine is a great idea; by the way! But once again, I cannot stress enough -why- my project was declined. Simply put, it 'violated the rules', but this topic was exempt. Anyone here support me?

Because it was too good to be shown here, so they(cough Robin cough) deleted it. That's what I've gathered from all the deleted projects.
Link to comment
Share on other sites

**Minor Update**
I'm taking things slow, I don't want to overlook anything. I figured my graphics implementation is at a good enough start to give it some rest, so I looked into the FMOD Libraries. As a result, I implemented FMOD with a Playlist/Sound support working in a separate thread. I've managed to stray away from the use of too many critical sections/mutex's. With a solid base for both graphics & sound, I'm going to sit down with some pen and paper to figure out which Data Structures I need to write and how I'm going to optimize the hell out of this thing.

I have some basic plans for items as well. In Mirage Based engines, you have a maximum number of items that can be made, each being sort of, 'copied' to the players with no room for change. If you create "Sword" that does 2 damage, the players will only ever be able to get a "Sword" that deals 2 damage. I want it to be set up in a way that I can have a sword with a +2 bonus to agility and you can have a sword with a +10 bonus to HP, how can this be done when every item is saved just once? Well it kind of can't. I have a few ideas as to how I want to implement this so I'll continue to follow up with any progress I make.

Oh, and I almost have a complete map editor tool written in C# (All tools will be written in C#).

Stay tuned folks.
Link to comment
Share on other sites

Okay here is the first milestone. Graphics/Sound are fully implemented and I threw together this little project to showcase them both. Go ahead and download & enjoy ^^

**Requirements**
**OS:** Windows Vista SP2, Windows 7
**The rest:** You don't need a lot.
[**Download**](http://www.MegaShare.com/3601755)
Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
**Engine Update**
Updated the main post with information as well as a download for the Alpha version of the World editor. Any feedback is appreciated!

ALSO

**Engine Update**
With the map editor fully functional, I'm going to tackle the rest of the editors, first starting with an item editor. Item's will be done a bit… differently I guess you could say. The editor will not load item files, they will load an **Item Index**. An item index is nothing more than a list of items (dynamic in size) that contain item info. So for example, instead of the game loading 1000 items, it will load specified item indices. This will give designers the opportunity to organize the way in which they create items.

If I am making a game, I might have an assortment like so:
Represents a Item Index (List)
Represents an actual item within an Index (List)

* General Items
* Gold
* Diamond
* Weapons
* Sword
* Dagger

The way items will be handled in-game will also work very different. Instead of storing integers to represent the items in a player's possession, they will actually have an array of their own items each able to be modified. So lets say a player picks up a sword, it will append a new item to his inventory, copy the values and boom, the player has a sword. Now the player can upgrade the sword and make it unique from any other sword. This is one way in which Mirage Based engines are very restrictive, I want to open that up a bit.

If you are having trouble understanding this concept or if you simply have questions, feel free to ask.
Link to comment
Share on other sites

  • 4 weeks later...
**Update**
It's been a while but trust me, there is much more to come… I've been working my ass off on a suite of new editors. They are MUCH more efficient and easy to use now then they were before. My next goal is to implement map animations/objects. As of now it remains with the same features as before but re-done properly being the first build was a simple test. I pushed GDI to it's limit. Rendering hundreds of tiles usually isn't GDI savvy but I managed to pull it off pretty decently.

[![](http://www.freemmorpgmaker.com/files/imagehost/pics/0603984f33c003e3a7ba70dfb8411b06.PNG)](http://www.freemmorpgmaker.com/files/imagehost/#0603984f33c003e3a7ba70dfb8411b06.PNG)

Stay tuned.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...