Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    90
  • comments
    59
  • views
    42414

3.141592654

Sign in to follow this  
diablo_tk

156 views

Finally got everyting back to normal and in working order.

Anyway heres a screenshot of my engine (click for bigger):


Also I have updated the movie on my website (FYI its not the best video but I wanted to get somthing up other then me coding :P):
fallenmoondesign

The images/movie shows a few things my engine can do, heres the sun down of what your seeing:
- A scaled and mid handled giant sprite being moved using built in function Move(dx, dy) and rotated using Turn(angle)
- Five images
- - (Starting from the left) A Alpha blended render using an alpha value of 126
- - An image rendered using the blend mode dark
- - An image rendered using the blend mode light
- - An image rendered using the blend mode solid
- - An image rendered using alpha mode and colored using vertex colors

Code for the demo ( not that nice )

main.cpp

/*

Fallen Engine - Test Project

Written by Stefan J Lulham

*/


// System includes
#include

// Library includes
#include "../Fallen Engine/system.h"
#include "../Fallen Engine/graphics.h"
#include "../Fallen Engine/input.h"
#include "../Fallen Engine/resource_manager.h"

// Game includes
#include "mech.h"

// Usee some library's
using namespace Fallen::System;
using namespace Fallen::Graphics;
using namespace Fallen::Input;
using namespace Fallen::ResourceManager;

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Load modules
CSystem::LoadModule();
CGraphics::LoadModule();
CInput::LoadModule();

// Set the interfaces
CSystem::SetInterface(CSystem::Interface_Win32());
CGraphics::SetInterface(CGraphics::Interface_OpenGL());
CInput::SetInterface(CInput::Interface_Win32());

// Setup the graphics context
CGraphics::CreateContext("Fallen Engine Demo 1", 800, 600, 32, true);
CGraphics::SetClearColor(127, 127, 147);
CGraphics::SetMaskColor(255, 0, 255);
CGraphics::SetVSync(true);
CGraphics::SetHandle(0, 0);

// Load resources
// -- Images
CResourceManager::LoadResource("image-mech", CGraphics::LoadImage("media//mech.bmp", 32, 32));

Mech * mech = new Mech();

bool running = true;
while (running == true)
{
running = CSystem::Update();
CInput::Update();

CGraphics::Cls();

mech->Update();
mech->Draw();

CGraphics::SetBlend(ALPHA);
CGraphics::SetDrawAlpha(126);
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("image-mech"), 10 + (0 * 35), 10);
CGraphics::SetDrawAlpha(255);

CGraphics::SetBlend(DARK);
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("image-mech"), 10 + (1 * 35), 10);

CGraphics::SetBlend(LIGHT);
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("image-mech"), 10 + (2 * 35), 10);

CGraphics::SetBlend(SOLID);
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("image-mech"), 10 + (3 * 35), 10);

CGraphics::SetBlend(ALPHA);
CGraphics::SetDrawColor(255, 0, 0);
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("image-mech"), 10 + (4 * 35), 10);
CGraphics::SetDrawColor(255, 255, 255);

CGraphics::Flip();

if (CInput::KeyPressed(KEY_ESCAPE))
running = false;
}

delete mech;

CGraphics::DestroyContext();

CGraphics::UnloadModule();
CSystem::UnloadModule();
CInput::UnloadModule();

CResourceManager::UnloadResources();

}






mech.h

#ifndef MECH_H
#define MECH_H

// Engine includes
#include "../Fallen Engine/system.h"
#include "../Fallen Engine/graphics.h"
#include "../Fallen Engine/input.h"
#include "../Fallen Engine/resource_manager.h"

// Engine namespace
using namespace Fallen::Graphics;
using namespace Fallen::Input;
using namespace Fallen::ResourceManager;

// Class def
class Mech
{
private:

CSprite *sprite;
int animiationSet;
int frame, ft;

void UpdateAnimation();

public:

Mech();
~Mech();

void Draw();
void Update();

void ChangeAnimationSet(int set);

};

#endif






mech.cpp

#include "mech.h"

Mech::Mech()
{
CResourceManager::LoadResource("sprite-mech", CGraphics::CreateSprite((CImage *)CResourceManager::GetResource("image-mech"), 400, 300));

this->animiationSet = 0;
this->sprite = (CSprite *)CResourceManager::GetResource("sprite-mech");

this->sprite->SetHandle(0.5, 0.5);
this->sprite->SetScale(10.5, 10.5);

this->frame = this->ft = 0;
}

Mech::~Mech()
{
this->animiationSet = 0;
}

void Mech::Update()
{
bool keyf = false;
bool walking = false;

if (CInput::KeyDown(KEY_UP))
{
this->sprite->Move(2, 0);
this->ChangeAnimationSet(0);

keyf = true;
walking = true;
}

if (CInput::KeyDown(KEY_DOWN))
{
this->sprite->Move(-2, 0);
this->ChangeAnimationSet(0);

keyf = true;
walking = true;
}

if (CInput::KeyDown(KEY_LEFT))
{
this->sprite->Turn(-1);
this->ChangeAnimationSet(0);
}

if (CInput::KeyDown(KEY_RIGHT))
{
this->sprite->Turn(1);
this->ChangeAnimationSet(0);
}

if (CInput::KeyDown(KEY_RCONTROL))
{
if (walking == false)
this->ChangeAnimationSet(1);
else
this->ChangeAnimationSet(2);

keyf = true;
}

if (keyf == false)
{
this->frame = 0;
this->sprite->SetFrame(0);
}
else
{
this->UpdateAnimation();
}

}

void Mech::Draw()
{
this->sprite->Draw();
}

void Mech::ChangeAnimationSet(int set)
{
this->animiationSet = set;
}

void Mech::UpdateAnimation()
{
this->ft ++;

if (this->ft > 8)
{
this->ft = 0;

this->frame ++;
if (this->frame > 3)
this->frame = 0;

this->sprite->SetFrame(this->frame + (4 * this->animiationSet));
}
}






Things on my to do:
* Add animaition support in to sprites
* Add a timer class
* Get delta timing working
* Create a function to draw a series of tiled images
* Add a z value to sprites
* Add z value sprite sorting
* Add blendmodes to sprites
* Add the sound module
* mores

EDIT: FYI
Video links will be direct to a download from now on.
Sign in to follow this  


2 Comments


Recommended Comments

Much more interesting video than last time =)

Looks like you have a good start, keep going and posting more videos of your progress!

Share this comment


Link to comment

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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!