iGame3D MurgaLua'd
|
Author |
Message |
chrimo
Member
  
Posts: 94
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
After a "Clean all targets" from XCode I got 197 erros ;-(
Everything based on svn "Updated to revision 368"
Bye
Christian
|
|
11-25-2007 06:38 AM |
|
 |
iGame3D
Moderator
  
Posts: 231
Group: Moderators
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
iGame3D Hello World
This is about our seventh system version since starting the project.
Onward marches progress.
I posted a link earlier and realised that the Data folder was missing.
You'll need to SVN the Data folder once we get this thing back on its tentacles.
Once you have a working version you should be able to drag this
script to the application icon (as a file from finder) and get Hello world.
-- text box creation 101
gTextboxes={}
-- note the image file and path you must have, its usually bundled.
gTextboxes[1]=make(ig3d_text_box, "Data/FontPngs/default32_1.png")
--font styling
setText_boxInfo(gTextboxes[1], IG3D_COLOR, 1.0,1.0,1.0,1)
setText_boxInfo(gTextboxes[1], IG3D_SIZE, 64)
--textbox position
setText_boxInfo(gTextboxes[1], IG3D_POSITION, 45 , 45)
--define a function for the game loop
function gamemodefunc()
setText_boxInfo(gTextboxes[1], IG3D_TEXT, "Hello World")
end
--tell engine what function to loop in game mode
game_func= gamemodefunc
--tell engine what the edit loop is, for now its the same
edit_func= gamemodefunc
ig3d_SetMode_i(4) -- play mode!
Scripts branch beginning in iGame3D Player.app/Data/game script.lua
To have the engine do nothing but hello world the script above as the game script would do the job.
Theoretically a whole game or program could be run from game script.lua,
but that would be madness.
Usually at the end of the game script we send a loadLevel command which seeks a folder within the Levels folder and runs a "load script.lua" there in, clearing any level content previously loaded.
I'm getting ahead of myself, next we'll interact using the example above.
And clear up any questions..?
This post was last modified: 11-26-2007 05:57 AM by iGame3D.
|
|
11-25-2007 09:20 AM |
|
 |
iGame3D
Moderator
  
Posts: 231
Group: Moderators
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
iGame3D Play and Edit Mode Toggle
ok here's the same code as above, only "hello world" is now a clock
and the escape key toggles between play and edit modes.
In edit mode you'll be able to move the text box around with the mouse.
gTextboxes={}
gTextboxes[1]=make(ig3d_text_box, "Data/FontPngs/default32_1.png")
setText_boxInfo(gTextboxes[1], IG3D_COLOR, 1.0,1.0,1.0,1)
setText_boxInfo(gTextboxes[1], IG3D_POSITION, 45 , 45)
setText_boxInfo(gTextboxes[1], IG3D_SIZE, 64)
function time()
return string.sub(os.date(),11,20)
end
--define a function for the game loop
function gamemodefunc()
setText_boxInfo(gTextboxes[1], IG3D_TEXT, time())
fltk_update();
char,code,name=input(false)
--Toggle to edit mode on escape key down
if name=="Escape" then ig3d_SetMode_i(1) end
end
--define a function to handle editing mode events
function editmodefunc()
setText_boxInfo(gTextboxes[1], IG3D_TEXT, time())
fltk_update();
char,code,name=input(false)
--Toggle to play mode on escape key down
if name=="Escape" then ig3d_SetMode_i(4) end
end
game_func= gamemodefunc--tell engine what the game loop is
edit_func= editmodefunc--tell engine what the edit loop is
ig3d_SetMode_i(4) --- play game!
Next up a murgaLua UI.
This post was last modified: 11-26-2007 05:58 AM by iGame3D.
|
|
11-26-2007 05:30 AM |
|
 |
iGame3D
Moderator
  
Posts: 231
Group: Moderators
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
iGame3D Background Color Controller UI
I made the UI in Fluid, save to cxx, iGame3D converts it to a lua file and runs it on drag and drop to the application icon.
This UI controls the background color.
--UI roller callback for color values
function color_Rollers()
--retrieve roller values
RedBack=Red_roller:value()
BlueBack=Blue_roller:value()
GreenBack=Green_roller:value()
--set the background color
setSceneInfo(IG3D_BACKGROUND_COLOR, RedBack, BlueBack, GreenBack)
--update labels
Red_roller:label(RedBack)
Blue_roller:label(BlueBack)
Green_roller:label(GreenBack)
end
--a Window with three rollers
do local object = fltk:Fl_Double_Window(155, 137);
window = object;
do BackgroundColor = fltk:Fl_Group(0, 10, 145, 125, "Background Color");
BackgroundColor:labelsize(9);
do Red_roller = fltk:Fl_Roller(10, 10, 135, 25);
Red_roller:type(1);
Red_roller:labelsize(9);
Red_roller:callback(color_Rollers);
end -- Fl_Roller* Red_roller
do Blue_roller = fltk:Fl_Roller(10, 55, 135, 25);
Blue_roller:type(1);
Blue_roller:labelsize(9);
Blue_roller:callback(color_Rollers);
end -- Fl_Roller* Blue_roller
do Green_roller = fltk:Fl_Roller(10, 100, 135, 25);
Green_roller:type(1);
Green_roller:labelsize(9);
Green_roller:callback(color_Rollers);
end -- Fl_Roller* Green_roller
Fl_Group:current(Fl_Group:current():parent());
end -- Fl_Group* BackgroundColor
Fl_Group:current(Fl_Group:current():parent());
end
--Activate this window
window:show();
ig3d_RebuildMacMenubar();
--lets ask tobi for a description of this section
if game_func==nil then
function runner()
fltk_update();
end
game_func=runner;
end
--UI style
Fl:scheme("plastic")
If we wanted to set the text color interactively we might do something like
setText_boxInfo(gTextboxes[1], IG3D_COLOR, RedBack, BlueBack, GreenBack,1)
Ok that about covers the very basics. What next?
This post was last modified: 11-26-2007 05:57 AM by iGame3D.
|
|
11-26-2007 05:55 AM |
|
 |
chrimo
Member
  
Posts: 94
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
Hi,
I give up, trying to compile the code at Leopard now ;-(
Coming back when seeing a sign at svn update :-)
In the meantime I try to understand the idea of your engine and murgaLua integration... I think, it seems to be a perfect environment for pseudo simulation (game like) robotics... Virtualisation ist the first step for my idea - simulation physics the next part :-)
Thanks for all
Bye
Christian
|
|
11-27-2007 06:01 AM |
|
 |
iGame3D
Moderator
  
Posts: 231
Group: Moderators
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
iGame3D Object import and control
I had a longer post, now lost to the ether, a more complex script was created for this demonstration but here's a quick and dirty version to demonstrate object creation at its leanest and direct translation of the object in space via the keyboard WASDRF keys.
--Create an object
gObjects[1]={}
gObjects[1].cObj=make(ig3d_object, "cube.wtf")
theCube=gObjects[1].cObj
setObjectInfo(theCube, IG3D_NAME, "cube1")
--define a function for the game loop
function MoveBoxWithWASDRF()
objectSpeed=0.02
--control the object with keyboard
fltk_update();
char, code, name=input(false)
--forward and back
if key("w","-") then zm= -objectSpeed end
if key("s","-") then zm=objectSpeed end
if zm~=0 then xm,ym=0,0 end
--left and right
if key("a","-") then xm= -objectSpeed end
if key("d","-") then xm=objectSpeed end
if xm~=0 then zm,ym=0,0 end
--up and down
if key("r","-") then ym=objectSpeed end
if key("f","-") then ym= -objectSpeed end
if ym~=0 then xm,zm=0,0 end
--stop the motion with spacebar
if key(" ","-") then xm,ym,zm=0,0,0 end
--get object coordinates
ox,oy,oz=getObjectInfo(theCube,IG3D_POSITION)
--modify coordinates
ox=ox+xm
oy=oy+ym
oz=oz+zm
--reposition object
setObjectInfo(theCube,IG3D_POSITION, ox,oy,oz)
end
--tell engine what function to loop in game mode
game_func= MoveBoxWithWASDRF
-- for now edit is the same as game loop
edit_func= MoveBoxWithWASDRF
ig3d_SetMode_i(4) -- play mode!
The same basic code can be used to create and manipulate other entities in the iGame3D scene. In a game scenario we don't manipulate objects so directly, we use physics, which I'll demonstrate soon with this robot thing in mind.
Perhaps a simple robot emulation program for me to test?
What data will the robot and 3D scene share?
This post was last modified: 11-27-2007 06:35 PM by iGame3D.
|
|
11-27-2007 06:34 PM |
|
 |
chrimo
Member
  
Posts: 94
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
Hi,
I use a very simple testprogram for my old simulation with murgaLua...
It uses a field of LEGO-brick and walls, moving around and should never collidate
with the walls :-)
What format is used for the moving object ?
Are png's OK for the static objects (bricks for the wall) ?
I think your environment will make me happy in the future :-)
Christian
-----------------------------------
-- Robot Programm for Lua Beginners
-- VERSION
-- @Author: chrimo@moccy.xdsnet.de
-- @DATE: May 2007
-- @LASTCHANGE: today
-----------------------------------
-- Robot for Beginners Project --
-- Simple framework for kids or young people without programming experience
-- functions are filled up step by step
--
--[[
Implemented robot functions:
**********************
robot.forward(speed)
robot.backward(speed)
robot.turn(degree);
robot.left(speed)
robot.right(speed)
robot.stop()
robot.off()
robot.beep(count)
robot.idle(mseconds)
robot.info()
--]]
-- nxt.SimInit();
near_distance=30;
-- robot.info(1);
while(nxt.ButtonRead() == -1) ) do
-- Simple Ant-Brain :D forward or back-left algorithm
if(robot.USRead(4) <= near_distance) then
robot.backward(100);
robot.left();
else
robot.forward(100);
end
end
|
|
11-28-2007 12:26 AM |
|
 |
Tobi
Junior Member
 
Posts: 20
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
Hi Christian,
You can use PNGs (and only PNGs) for your textures.
Those textures can be applied to both dynamic objects and the static world, ie brickwalls. We'd be glad to see some robot action happening in iGame3D!
Getting back to the linking problem:
Obviously there is a problem with the newton physics engine.
It would be great help if you could download the mac version of this engine from http://www.newtongamedynamics.com and try to build it with your xcode and tell us the results of this of course 
Regards,
Tobi
Hi,
I use a very simple testprogram for my old simulation with murgaLua...
It uses a field of LEGO-brick and walls, moving around and should never collidate
with the walls :-)
What format is used for the moving object ?
Are png's OK for the static objects (bricks for the wall) ?
I think your environment will make me happy in the future :-)
Christian
|
|
11-28-2007 06:04 AM |
|
 |
chrimo
Member
  
Posts: 94
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
Hi Tobi,
give me a second, I try it now...
Bye
Christian
|
|
11-28-2007 06:32 AM |
|
 |
chrimo
Member
  
Posts: 94
Group: Registered
Joined: May 2007
Status:
Offline
Reputation: 0
|
RE: iGame3D MurgaLua'd
Result:
download, extract, double click xcode.project-file, build and run...
The earth rotates very fast !
What now ?
Christian
|
|
11-28-2007 06:36 AM |
|
 |
|