I hope not, I can't imagine rogerborg as a Kendo master3DModelerMan wrote:No way... you do kendo?
Best way to program?
-
The Onslaught
- Posts: 41
- Joined: Mon Jan 29, 2007 3:33 pm
-
Dark_Kilauea
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
Rogerborg would probably make a good Kendo instructor. You'd either learn to defend yourself within a couple days, or you'd leave.
Anyway, to actually add to the topic at hand, yes, FSM's are still used everywhere. The Source Engine's AI is heavily FSM based, running "thinking" functions every AI frame to decide which state the AI should change to.
Anyway, to actually add to the topic at hand, yes, FSM's are still used everywhere. The Source Engine's AI is heavily FSM based, running "thinking" functions every AI frame to decide which state the AI should change to.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
-
3DModelerMan
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
hmmm
I guess so, could you recomend me some good books or tutorials on finite state machines?.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
3DModelerMan
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
thanks
Thanks!
.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
We can't fault his tenacity though. I see him having a promising career in either politics, or panhandling.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
3DModelerMan
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
huh
My mom said I would be a good politician too... I guess I'm just more of a modeler than a programmer, but I enjoy programming too.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
3DModelerMan
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
ummm?
So what would be the best way to devide this code up into different functions to where I can have different menu screens?.
Code: Select all
#include <irrlicht.h>
#include "newton.h"
#include "tumle.h"
#include "SDL.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace tumle;
//{control variables
int P1_button_press = 0;
enum P1_hat_state { UP,DOWN,LEFT,RIGHT,MIDDLE };
//}
//initialize first joystick globaly
SDL_Joystick* joystick1 = 0;
int main(int argc, char *argv[])
{
//{add classes
SDL_Event event;
//}
//{initialize SDL
if(SDL_Init( SDL_INIT_JOYSTICK|SDL_INIT_TIMER|SDL_INIT_VIDEO ) < 0) return 1;
//}
//{create an irrlicht device
IrrlichtDevice* device = createDevice(EDT_OPENGL, dimension2d<s32>(1024, 768), 32,
true, false, true, 0);
//if the device can't be created exit the program
if (!device) return 1;
//{pointers
//create and check driver
IVideoDriver* driver = device->getVideoDriver();
if (!driver) return 1;
//create and check smgr
ISceneManager* smgr = device->getSceneManager();
if (!smgr) return 1;
//create and check guienv
IGUIEnvironment* guienv = device->getGUIEnvironment();
if (!guienv) return 1;
//create and check physics manager
IPhysicsManager* pmgr = createPhysicsManager(device);
if (!pmgr) return 1;
//}
//}
//=======================================================================
//{menu screen variables
int menu_item = 1;
bool in_main_menu = true;
//}
//{add menu screen objects
//{add menu screen background image
IGUIImage* menu_bkg = guienv->addImage(driver->getTexture("menu_background.png"),
position2d<int>(0,0));
//}
//{add logo image
IGUIImage* logo = guienv->addImage(driver->getTexture("logo.png"),
position2d<int>(25,10));
//}
//{sky background
IMeshSceneNode* sky = smgr->addMeshSceneNode(smgr->getMesh("cylinder.obj") );
if (sky)
{
sky->setPosition(vector3df(0,-10,0) );
sky->setScale(vector3df(550,550,550) );
sky->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
sky->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
sky->setMaterialFlag(EMF_LIGHTING, false);
sky->setMaterialTexture( 0, driver->getTexture("menu_clouds.bmp") );
//rotation animator
ISceneNodeAnimator* rotate = smgr->createRotationAnimator(core::vector3df(0,0.04f,0));
sky->addAnimator(rotate);
rotate->drop();
}
//}
//{battle background
IMeshSceneNode* battle = smgr->addMeshSceneNode(smgr->getMesh("battlefield_stage.obj") );
if (battle)
{
battle->setScale(vector3df(3,3,3) );
battle->setPosition(vector3df(0,-10,0) );
battle->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
battle->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
battle->setMaterialFlag(EMF_LIGHTING, true);
battle->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
battle->setMaterialTexture( 0, driver->getTexture("battlefield_UV_map.png") );
battle->getMaterial(0).EmissiveColor.set(0,100,100,100);
}
//}
//{camera
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, vector3df(0,5,0), vector3df(0,0,0));
ISceneNodeAnimator* fly = smgr->createFlyCircleAnimator (core::vector3df(0,5,0),130.0f, -0.0001f);
camera->addAnimator(fly);
fly->drop();
//}
//{light
//add light
ILightSceneNode* light = smgr->addLightSceneNode(0, vector3df(-15,5,-105), video::SColorf(1.0f, 1.0f, 1.0f));
//}
//{add P1 button is selected image
IGUIImage* P1_brawl_selected = guienv->addImage(driver->getTexture("pressed_button.png"),
position2d<int>(650,10));
//}
//{add P1 button image
IGUIImage* P1_brawl_button = guienv->addImage(driver->getTexture("menu_button.png"),
position2d<int>(650,10));
//}
//{add P1 button text image
IGUIImage* P1_brawl_text = guienv->addImage(driver->getTexture("P1_brawl.png"),
position2d<int>(650,10));
//}
//{add P2 button is selected image
IGUIImage* P2_brawl_selected = guienv->addImage(driver->getTexture("pressed_button.png"),
position2d<int>(650,120));
//}
//{add P2 button image
IGUIImage* P2_brawl_button = guienv->addImage(driver->getTexture("menu_button.png"),
position2d<int>(650,120));
//}
//{add adventure mode button is selected image
IGUIImage* adventure_selected = guienv->addImage(driver->getTexture("pressed_button.png"),
position2d<int>(650,230));
//}
//{add adventure mode button image
IGUIImage* adventure_button = guienv->addImage(driver->getTexture("menu_button.png"),
position2d<int>(650,230));
//}
//{add guess what button is selected image
IGUIImage* guess_what_selected = guienv->addImage(driver->getTexture("pressed_button.png"),
position2d<int>(650,340));
//}
//{add guess what button image
IGUIImage* guess_what_button = guienv->addImage(driver->getTexture("menu_button.png"),
position2d<int>(650,340));
//}
//{add guess what button text image
IGUIImage* guess_what_text = guienv->addImage(driver->getTexture("guess_what.png"),
position2d<int>(650,340));
//}
//{add quit button is selected image
IGUIImage* quit_button_selected = guienv->addImage(driver->getTexture("pressed_button.png"),
position2d<int>(650,450));
//}
//{add quit button image
IGUIImage* quit_button = guienv->addImage(driver->getTexture("menu_button.png"),
position2d<int>(650,450));
//}
//{add quit button text image
IGUIImage* quit_text = guienv->addImage(driver->getTexture("quit.png"),
position2d<int>(650,445));
//}
//{add answer image
IGUIImage* guess_what_answer = guienv->addImage(driver->getTexture("answer.png"),
position2d<int>(0,0));
guess_what_answer->setVisible(false);
//}
//}
//{error text objects
//{error text
IGUIStaticText* joy_error = guienv->addStaticText(L"Please insert a joystick or gamepad...",rect<s32>(15,1,260,22), true);
joy_error->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
joy_error->move(position2d<int>(350,350) );
//}
//}
//{open joysticks
//Open joystick1
SDL_JoystickEventState(SDL_ENABLE);
joystick1 = SDL_JoystickOpen(0);
//}
//main game loop
while( device->run() )
{
//=======================================================================
//{check joysticks
if ( SDL_NumJoysticks() < 1 ) joy_error->setVisible(true); else joy_error->setVisible(false);
if ( joystick1 == NULL ) joy_error->setVisible(true);
//}
//{menu screen logic functions
//{menu item wrapping
if ( menu_item < 1 ) menu_item = 5;
if ( menu_item > 5 ) menu_item = 1;
//}
//{menu item selection image
//=======================================================================
if ( menu_item == 1 )
{
P1_brawl_button->setVisible(false);
P2_brawl_button->setVisible(true);
adventure_button->setVisible(true);
guess_what_button->setVisible(true);
quit_button->setVisible(true);
}
//=======================================================================
//=======================================================================
if ( menu_item == 2 )
{
P1_brawl_button->setVisible(true);
P2_brawl_button->setVisible(false);
adventure_button->setVisible(true);
guess_what_button->setVisible(true);
quit_button->setVisible(true);
}
//=======================================================================
//=======================================================================
if ( menu_item == 3 )
{
P1_brawl_button->setVisible(true);
P2_brawl_button->setVisible(true);
adventure_button->setVisible(false);
guess_what_button->setVisible(true);
quit_button->setVisible(true);
}
//=======================================================================
//=======================================================================
if ( menu_item == 4 )
{
P1_brawl_button->setVisible(true);
P2_brawl_button->setVisible(true);
adventure_button->setVisible(true);
guess_what_button->setVisible(false);
quit_button->setVisible(true);
}
//=======================================================================
//=======================================================================
if ( menu_item == 5 )
{
P1_brawl_button->setVisible(true);
P2_brawl_button->setVisible(true);
adventure_button->setVisible(true);
guess_what_button->setVisible(true);
quit_button->setVisible(false);
}
//=======================================================================
//}
//}
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_JOYBUTTONDOWN: /* Handle Joystick Button Presses */
if ( event.jbutton.button == 0 && in_main_menu == true )
{
//{ menu selection
if ( menu_item == 1 )
{
in_main_menu = false;
menu_bkg->remove();
logo->remove();
battle->remove();
sky->remove();
guess_what_answer->remove();
P1_brawl_button->remove();
P1_brawl_selected->remove();
P1_brawl_text->remove();
camera->remove();
light->remove();
P2_brawl_button->remove();
P2_brawl_selected->remove();
quit_button->remove();
quit_button_selected->remove();
quit_text->remove();
guess_what_answer->remove();
guess_what_button->remove();
guess_what_selected->remove();
guess_what_text->remove();
}
if ( menu_item == 4 )
{
guess_what_answer->setVisible(true);
}
if ( menu_item == 5 )
{
device->closeDevice();
SDL_JoystickClose(joystick1);
atexit(SDL_Quit);
return 0;
}
//}
}
break;
case SDL_JOYHATMOTION: /* Handle Hat Motion */
if ( event.jhat.value & SDL_HAT_UP && in_main_menu == true )
{
menu_item--;
}
if ( event.jhat.value & SDL_HAT_DOWN && in_main_menu == true )
{
menu_item++;
}
break;
}
}
//=======================================================================
//{update the world
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
//update the newton world
pmgr->update();
SDL_JoystickUpdate();
P1_button_press = 0;
P1_hat_state MIDDLE;
//}
//=======================================================================
}
device->drop();
SDL_JoystickClose(joystick1);
atexit(SDL_Quit);
return 0;
}
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
You may, but there really are limits to how much time we're going to sink into teaching C 101.The forum wrote:You may also post general programming questions here.
Seriously, there are plenty of general C/C++ resources out there. You don't have to keep asking these non Irrlicht related questions here.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
3DModelerMan
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
ohhh
No I just meant, should I put it all into a few headers and cpp's or is it best to do seperate levels as seperate funcs.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar