News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
iGame3D MurgaLua'd
Author Message
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #1
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.

Code:
--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
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
iGame3D MurgaLua'd - iGame3D - 11-24-2007, 06:54 PM
RE: iGame3D MurgaLua'd - chrimo - 11-24-2007, 09:36 PM
RE: iGame3D MurgaLua'd - chrimo - 11-24-2007, 09:53 PM
RE: iGame3D MurgaLua'd - chrimo - 11-24-2007, 10:13 PM
RE: iGame3D MurgaLua'd - chrimo - 11-24-2007, 10:50 PM
RE: iGame3D MurgaLua'd - chrimo - 11-24-2007, 11:21 PM
RE: iGame3D MurgaLua'd - Tobi - 11-25-2007, 04:36 AM
RE: iGame3D MurgaLua'd - iGame3D - 11-25-2007, 05:14 AM
RE: iGame3D MurgaLua'd - Tobi - 11-25-2007, 05:37 AM
RE: iGame3D MurgaLua'd - chrimo - 11-25-2007, 06:16 AM
RE: iGame3D MurgaLua'd - chrimo - 11-25-2007, 06:38 AM
iGame3D Hello World - iGame3D - 11-25-2007, 09:20 AM
RE: iGame3D MurgaLua'd - chrimo - 11-27-2007, 06:01 AM
iGame3D Object import and control - iGame3D - 11-27-2007 06:34 PM
RE: iGame3D MurgaLua'd - chrimo - 11-28-2007, 12:26 AM
RE: iGame3D MurgaLua'd - Tobi - 11-28-2007, 06:04 AM
RE: iGame3D MurgaLua'd - chrimo - 11-28-2007, 06:32 AM
RE: iGame3D MurgaLua'd - chrimo - 11-28-2007, 06:36 AM
RE: iGame3D MurgaLua'd - Tobi - 11-28-2007, 07:11 AM
RE: iGame3D MurgaLua'd - chrimo - 11-28-2007, 07:29 AM
RE: iGame3D MurgaLua'd - Tobi - 11-28-2007, 07:43 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 02:58 AM
RE: iGame3D MurgaLua'd - iGame3D - 11-29-2007, 03:25 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 03:50 AM
RE: iGame3D MurgaLua'd - iGame3D - 11-29-2007, 04:02 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 06:25 AM
RE: iGame3D MurgaLua'd - Tobi - 11-29-2007, 07:07 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 07:29 AM
RE: iGame3D MurgaLua'd - Tobi - 11-29-2007, 07:45 AM
RE: iGame3D MurgaLua'd - Tobi - 11-29-2007, 07:52 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 07:42 AM
RE: iGame3D Data Directories - iGame3D - 11-29-2007, 09:10 AM
RE: iGame3D MurgaLua'd - chrimo - 11-29-2007, 09:24 AM
RE: iGame3D MurgaLua'd - chrimo - 12-02-2007, 10:56 PM
RE: iGame3D MurgaLua'd - iGame3D - 12-03-2007, 04:46 AM
RE: iGame3D MurgaLua'd - chrimo - 12-03-2007, 06:50 AM
RE: iGame3D MurgaLua'd - Tobi - 12-03-2007, 07:09 AM
RE: iGame3D MurgaLua'd - chrimo - 12-09-2007, 12:18 AM
RE: iGame3D MurgaLua'd - chrimo - 12-09-2007, 09:32 PM
RE: iGame3D MurgaLua'd - mikshaw - 12-12-2007, 02:47 PM
RE: iGame3D MurgaLua'd - chrimo - 12-12-2007, 08:35 PM
RE: iGame3D MurgaLua'd - mikshaw - 12-13-2007, 01:31 AM
RE: iGame3D MurgaLua'd - iGame3D - 12-13-2007, 02:55 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: