New Cafu user. Puzzled on how to start.
- RichardMarks
- Posts:4
- Joined:2013-05-16, 06:24
- Contact:
Hi there.
I just found Cafu through the game engine list on wikipedia and so far, I'm pretty impressed with what appears to be a truly powerful and useful collection of software.
I built Cafu from source via the git repo, I've duplicated the DeathMatch game to have some "ground" to work from.
I've read through the .cpp and .hpp files in the /Code/ directory in the game folder, and what I think I see are implementations for the various entities and objects/functionality of the FPS game DeathMatch. But I don't see any sort of initialization of the camera, nothing loading up the environment, positioning entities, nothing that I would normally find in an open source project.
What I would like to know is where do I look to begin implementing a top-down perspective for an RPG project?
I know that it's going to take some effort, I just need to find out where that effort need be applied.
I hope someone can assist.
Thank you for your time.
I just found Cafu through the game engine list on wikipedia and so far, I'm pretty impressed with what appears to be a truly powerful and useful collection of software.
I built Cafu from source via the git repo, I've duplicated the DeathMatch game to have some "ground" to work from.
I've read through the .cpp and .hpp files in the /Code/ directory in the game folder, and what I think I see are implementations for the various entities and objects/functionality of the FPS game DeathMatch. But I don't see any sort of initialization of the camera, nothing loading up the environment, positioning entities, nothing that I would normally find in an open source project.
What I would like to know is where do I look to begin implementing a top-down perspective for an RPG project?
I know that it's going to take some effort, I just need to find out where that effort need be applied.
I hope someone can assist.
Thank you for your time.
Re: New Cafu user. Puzzled on how to start.
Hi Richard,
welcome to the Cafu forums!
Per default, the camera is positioned at the origin of the local human player, and oriented accordingly. The setup is a bit complicated by the fact that (both in a networked multi-player game as well as in a local single-player game) we have to use the "predicted" origin and angles for the camera setup.
Here are some examples on how this can be implemented: (Unfortunately, I cannot tell if these patches still apply to the current code, but they may at least give you some ideas.)
Does this help?
welcome to the Cafu forums!
At this time, the camera is setup not in the game code, but in the Cafu Engine itself (subdirectoryRichardMarks wrote:I've read through the .cpp and .hpp files in the /Code/ directory in the game folder, and what I think I see are implementations for the various entities and objects/functionality of the FPS game DeathMatch. But I don't see any sort of initialization of the camera, nothing loading up the environment, positioning entities, nothing that I would normally find in an open source project.
What I would like to know is where do I look to begin implementing a top-down perspective for an RPG project?
Ca3DE
and Ca3DE/Client
), essentially beginning in Ca3DE/Client/ClientStateInGame.cpp
, line 374.Per default, the camera is positioned at the origin of the local human player, and oriented accordingly. The setup is a bit complicated by the fact that (both in a networked multi-player game as well as in a local single-player game) we have to use the "predicted" origin and angles for the camera setup.
Here are some examples on how this can be implemented: (Unfortunately, I cannot tell if these patches still apply to the current code, but they may at least give you some ideas.)
Does this help?
Best regards,
Carsten
Carsten
- RichardMarks
- Posts:4
- Joined:2013-05-16, 06:24
- Contact:
Re: New Cafu user. Puzzled on how to start.
Thank you for giving me a direction to search in Carsten. I think that I need to spend a little more time with Cafu before I can attempt the project I want to use it for.
In that light, I have been trying to make a stripped-down bare-minimum project using the Cafu documentation, wiki, and the DeathMatch files as a reference for how to go about the process.
I managed to figure out how to create my own menu GUI using CaWE and then how to make it functional by adding lua code to the **_main.cgui file. I also figured out that I need at least one texture and material in order to get CaWE to not complain on startup.
I stripped the Code/ directory down to the following files which I think are the minimum necessary to get things working. I might be wrong - which will lead into my next set of questions.
I removed all the entity definitions from EntityClassDefs.lua except for worldspawn, info_generic, and info_player_start. I also stripped out the now unused code from the GameImpl.* files.
I created a single room map in CaWE and added an info_player_start entity to the map. I compiled the map into a .cw world and added a .lua file to my Worlds/ folder which only has a reloadscript function implementation.
I moved the DeathMatch folder out of the Games/ folder so that my project is the only one that exists (So as to identify as dependency on the DeathMatch files).
I get no problems in compiling the project (calling scons in the cafu root directory), and I have no problem running the engine with my project.
When I start up Cafu.exe I get the custom GUI menu, however when I try to start the game by clicking on the Start Button, nothing happens. I ran Cafu with --verbose -log:log.log and checked the output, and no errors were triggered.
Below are the _init and _main cgui file contents for my menu GUI.
Am I missing something vital here? Why is my basic_room map not loading in? Is there additional required code that I removed which actually gets the map loaded up?
Please advise. Thank you.
In that light, I have been trying to make a stripped-down bare-minimum project using the Cafu documentation, wiki, and the DeathMatch files as a reference for how to go about the process.
I managed to figure out how to create my own menu GUI using CaWE and then how to make it functional by adding lua code to the **_main.cgui file. I also figured out that I need at least one texture and material in order to get CaWE to not complain on startup.
I stripped the Code/ directory down to the following files which I think are the minimum necessary to get things working. I might be wrong - which will lead into my next set of questions.
- BaseEntity.cpp
- BaseEntity.hpp
- EntityCreateParams.cpp
- EntityCreateParams.hpp
- GameImpl.cpp
- GameImpl.hpp
- GameInfo.cpp
- GameInfo.hpp
- InfoGeneric.cpp
- InfoGeneric.hpp
- InfoPlayerStart.cpp
- InfoPlayerStart.hpp
- Interpolator.hpp
- LinkerScript
- SConscript
I removed all the entity definitions from EntityClassDefs.lua except for worldspawn, info_generic, and info_player_start. I also stripped out the now unused code from the GameImpl.* files.
I created a single room map in CaWE and added an info_player_start entity to the map. I compiled the map into a .cw world and added a .lua file to my Worlds/ folder which only has a reloadscript function implementation.
I moved the DeathMatch folder out of the Games/ folder so that my project is the only one that exists (So as to identify as dependency on the DeathMatch files).
I get no problems in compiling the project (calling scons in the cafu root directory), and I have no problem running the engine with my project.
When I start up Cafu.exe I get the custom GUI menu, however when I try to start the game by clicking on the Start Button, nothing happens. I ran Cafu with --verbose -log:log.log and checked the output, and no errors were triggered.
Below are the _init and _main cgui file contents for my menu GUI.
Code: Select all
-- This is a Cafu engine GUI script file, written by CaWE, the Cafu World Editor.
-- You CAN edit this file manually, but note that CaWE may overwrite your changes.
-- It is recommended that you place all your customizations like method overrides
-- and effects into a separate .cgui file that calls dofile() for including this.
-- Instantiation of all windows.
-- *****************************
MainUIWindow=gui:new("WindowT", "MainUIWindow");
QuitButton=gui:new("WindowT", "QuitButton");
StartButton=gui:new("WindowT", "StartButton");
-- Set the GUIs root window.
-- *************************
gui:SetRootWindow(MainUIWindow);
-- Setup the window hierarchy.
-- ***************************
MainUIWindow:AddChild(QuitButton);
MainUIWindow:AddChild(StartButton);
-- Initialization of the window contents ("constructor code").
-- ***********************************************************
function MainUIWindow:OnInit()
self:GetTransform():set("Pos", 0, 0)
self:GetTransform():set("Size", 500, 400)
local c1 = gui:new("ComponentBorderT")
c1:set("Width", 1)
c1:set("Color", 0, 1, 0)
c1:set("Alpha", 1)
local c2 = gui:new("ComponentTextT")
c2:set("Text", "Testing Cafu")
c2:set("Font", "Fonts/Impact")
c2:set("Scale", 1)
c2:set("Padding", 0, 0)
c2:set("Color", 0, 1, 0)
c2:set("Alpha", 1)
c2:set("hor. Align", 0)
c2:set("ver. Align", 0)
self:AddComponent(c1, c2)
gui:activate (true);
gui:setInteractive(true);
gui:showMouse (true);
gui:setFocus (StartButton);
end
function QuitButton:OnInit()
self:GetTransform():set("Pos", 20, 340)
self:GetTransform():set("Size", 130, 40)
local c1 = gui:new("ComponentTextT")
c1:set("Text", "Quit Game")
c1:set("Font", "Fonts/Arial")
c1:set("Scale", 0.4)
c1:set("Padding", 0, 0)
c1:set("Color", 1, 0, 0)
c1:set("Alpha", 1)
c1:set("hor. Align", 0)
c1:set("ver. Align", 0)
local c2 = gui:new("ComponentBorderT")
c2:set("Width", 0.6)
c2:set("Color", 1, 0, 0)
c2:set("Alpha", 1)
self:AddComponent(c1, c2)
end
function StartButton:OnInit()
self:GetTransform():set("Pos", 355, 345)
self:GetTransform():set("Size", 130, 40)
local c1 = gui:new("ComponentTextT")
c1:set("Text", "Start Game")
c1:set("Font", "Fonts/Arial")
c1:set("Scale", 0.4)
c1:set("Padding", 0, 0)
c1:set("Color", 0, 1, 0)
c1:set("Alpha", 1)
c1:set("hor. Align", 0)
c1:set("ver. Align", 0)
local c2 = gui:new("ComponentBorderT")
c2:set("Width", 0.6)
c2:set("Color", 0, 1, 0)
c2:set("Alpha", 1)
self:AddComponent(c1, c2)
end
Code: Select all
dofile("Games/TestProject1/GUIs/MainMenu/MainMenu_init.cgui");
function MainUIWindow:OnKeyPress(Key)
if (Key==1) then
if (self.ClientState=="ingame") then
gui:close();
else
QuitButton:OnMouseButtonUp();
end
return true;
end
return false;
end
function QuitButton:OnMouseEnter()
self:GetComponent("Border"):set("Color", 1.0, 1.0, 0.0)
self:GetComponent("Text"):interpolate("Scale", 0.4, 0.45, 500)
end
function QuitButton:OnMouseLeave()
self:GetComponent("Border"):set("Color", 1, 0, 0)
self:GetComponent("Text"):interpolate("Scale", 0.45, 0.4, 500)
end
function QuitButton:OnMouseButtonUp()
if (self.IsShuttingDown) then return true; end;
self.IsShuttingDown=true;
gui:showMouse(false);
ci.RunCommand("quit=true;");
return true;
end
function StartGame(WorldName)
waitFrame();
ci.RunCommand("MusicStop();");
ci.RunCommand("changeLevel('"..WorldName.."');");
if (MainUIWindow.ServerState~="maploaded") then
Console.Print("Cannot load"..WorldName.."!");
return
end
ci.RunCommand("connect('localhost', "..ci.GetValue("dlg_svPortNr")..");");
end
function StartButton:OnMouseEnter()
self:GetComponent("Border"):set("Color", 1.0, 1.0, 1.0)
self:GetComponent("Text"):interpolate("Scale", 0.4, 0.45, 500)
end
function StartButton:OnMouseLeave()
self:GetComponent("Border"):set("Color", 0, 1, 0)
self:GetComponent("Text"):interpolate("Scale", 0.45, 0.4, 500)
end
function StartButton:OnMouseButtonUp()
if (MainUIWindow.ServerState~="idle") then return; end
thread(StartGame, "basic_room");
return true;
end
Please advise. Thank you.
Re: New Cafu user. Puzzled on how to start.
Hi Richard,
can I pull your minimal set of source files somewhere?
Alternatively, could you please zip the files, and attach here or send to my email?
It's easier to tell what the problem is when I can see this live.
can I pull your minimal set of source files somewhere?
Alternatively, could you please zip the files, and attach here or send to my email?
It's easier to tell what the problem is when I can see this live.
Best regards,
Carsten
Carsten
- RichardMarks
- Posts:4
- Joined:2013-05-16, 06:24
- Contact:
Re: New Cafu user. Puzzled on how to start.
Sure. I tossed the project into my github.
Thanks for the help.
Code: Select all
$ cd cafu/Games
$ git clone https://github.com/RichardMarks/CafuTestProject.git
Re: New Cafu user. Puzzled on how to start.
Hi Richard,
I took a look at your project last night:
The first problem was that some paths were still mentioning
As the next step, I added some calls to
The attached patch shows my changes to the paths and additions of
I took a look at your project last night:
The first problem was that some paths were still mentioning
TestProject1
where it should have been CafuTestProject
. This prevented the in-game console from loading (opened with the F1
). While under Linux all output is printed both to the shell where the Cafu binary was started as well as to the in-game console, under Windows some of the output only goes to the in-game console.As the next step, I added some calls to
Console.Print()
to your MainMenu_main.cgui
file to see where it failed in the processing of the "Start Game" button. It turned out that you need the callback functions OnClientStateChanged()
and OnServerStateChanged()
as in the DeathMatch main menu file, which in turn call MainMenu:UpdateUI()
.The attached patch shows my changes to the paths and additions of
Console.Print()
calls. The resulting output at the console was only "-2" for me; I hope this helps you with the next steps. - Attachments
-
- fix_paths.patch
- (1.93KiB)Downloaded 255 times
Best regards,
Carsten
Carsten
- RichardMarks
- Posts:4
- Joined:2013-05-16, 06:24
- Contact:
Re: New Cafu user. Puzzled on how to start.
Hey, thanks. The path issue happened when I made the git repo version. Oops.
The missing OnServer and OnClient state change callbacks helped me get further.
I also added more Console prints in the FileSys and MaterialManager so that my log tells me everything the engine tries to open and helped me find more missing files.
I'm outta time to spend on this for now, but later I'll work on getting a minimal demo working.
The missing OnServer and OnClient state change callbacks helped me get further.
I also added more Console prints in the FileSys and MaterialManager so that my log tells me everything the engine tries to open and helped me find more missing files.
I'm outta time to spend on this for now, but later I'll work on getting a minimal demo working.
Who is online
Users browsing this forum: No registered users and 36 guests