Jump to content

Aily

Members
  • Posts

    465
  • Joined

  • Last visited

Everything posted by Aily

  1. Hi Josh. Here have strange things. That's code to render to simple 2D texture, it works great Framework leadwerks.engine registerabstractpath AppDir Graphics 800,600 createworld cp=createpivot() cam=createcamera() cameraclearcolor cam,vec4(.5,.5,.5,1) entityparent cam,cp moveentity cam,vec3(0,1,-1) pointentity cam,cp c=createsphere() mat=creatematerial() setmaterialshader mat,loadshader("abstract::mesh.vert","abstract::mesh_diffuse.frag") tex=createtexture(256,256) setmaterialtexture mat,tex,0 paintentity c,mat tex_buffer=createbuffer(256,256,BUFFER_COLOR) setcolorbuffer tex_buffer,tex,0 setbuffer tex_buffer SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 Repeat If KeyHit(key_escape) Or AppTerminate() End turnentity cp,vec3(0,.2,0) setbuffer backbuffer() renderworld Flip 1 Forever Here's the code to load cubemap from file, and just to check that mesh_cubemap.frag works: Framework leadwerks.engine registerabstractpath AppDir Graphics 800,600 createworld cp=createpivot() cam=createcamera() cameraclearcolor cam,vec4(.5,.5,.5,1) entityparent cam,cp moveentity cam,vec3(0,1,-1) pointentity cam,cp c=createsphere() mat=creatematerial() setmaterialshader mat,loadshader("abstract::mesh_cubemap.vert","abstract::mesh_cubemap.frag") tex=loadtexture("abstract::sunol_cubemap.dds") setmaterialtexture mat,tex,0 paintentity c,mat Repeat If KeyHit(key_escape) Or AppTerminate() End turnentity cp,vec3(0,.2,0) setbuffer backbuffer() renderworld Flip 1 Forever And this is code like above, but drawing to cubemap: Framework leadwerks.engine registerabstractpath AppDir Graphics 800,600 createworld cp=createpivot() cam=createcamera() cameraclearcolor cam,vec4(.5,.5,.5,1) entityparent cam,cp moveentity cam,vec3(0,1,-1) pointentity cam,cp c=createsphere() mat=creatematerial() setmaterialshader mat,loadshader("abstract::mesh_cubemap.vert","abstract::mesh_cubemap.frag") tex=createcubemap(256,256) setmaterialtexture mat,tex,0 paintentity c,mat tex_buffer_0=createbuffer(256,256,BUFFER_COLOR) tex_buffer_1=createbuffer(256,256,BUFFER_COLOR) tex_buffer_2=createbuffer(256,256,BUFFER_COLOR) tex_buffer_3=createbuffer(256,256,BUFFER_COLOR) tex_buffer_4=createbuffer(256,256,BUFFER_COLOR) tex_buffer_5=createbuffer(256,256,BUFFER_COLOR) setcolorbuffer tex_buffer_0,tex,0,0 setcolorbuffer tex_buffer_1,tex,0,1 setcolorbuffer tex_buffer_2,tex,0,2 setcolorbuffer tex_buffer_3,tex,0,3 setcolorbuffer tex_buffer_4,tex,0,4 setcolorbuffer tex_buffer_5,tex,0,5 setbuffer tex_buffer_0 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 setbuffer tex_buffer_1 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 setbuffer tex_buffer_2 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 setbuffer tex_buffer_3 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 setbuffer tex_buffer_4 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 setbuffer tex_buffer_5 SetColor vec3(0) DrawRect 0,0,256,256 SetColor vec3(1) DrawRect 50,50,100,100 Repeat If KeyHit(key_escape) Or AppTerminate() End turnentity cp,vec3(0,.2,0) setbuffer backbuffer() renderworld Flip 1 Forever As you can see - i'm using same technique as draw to 2D texture - assign it to buffer, But with cubemaps im assigning cubefaces to 6 buffers. Think this code must be work, but it didnt Maybe you can show the correct way to use render to cubemaps? Thanks.
  2. You need to flip by Y DrawImage(texture, 0 , Y , X , -Y )
  3. Long time fighting fith charachter controller don't give good result for my Last Chapter platformer. So Arbuz give me a good idea - make my own AABB collisions engine, because Last Chapter in fact have only box bodies. Hahaha!!!! Now with this i can make movable platforms, accurate to metall attachement player and much more! This is AABB collisions base, maybe someone will be make such platformer Global bodies:TList=CreateList() Type body Field x#,y# ' aa Field w#,h# ' bb Field width# Field height# End Type Function add_body:body(x#,y#,width#,height#) Local b:body=New body b.x=x-width/2 b.y=y-height/2 b.width=width b.height=height b.w=b.x+width b.h=b.y+height ListAddLast bodies,b Return b End Function Function render_bodies() For b:body=EachIn bodies SetColor 255,255,255 DrawRect b.x,b.y,b.width,b.height SetColor 50,50,50 DrawRect b.x+1,b.y+1,b.width-2,b.height-2 Next End Function Function ol(pv#,cv#,nv#) Return cv>pv And cv<nv End Function Function move_body(b:body,x#,y#) nx#=b.x+x ny#=b.y+y nw#=b.w+x nh#=b.h+y fx#=x fy#=y For bb:body=EachIn bodies If bb=b Continue If fx>0 If ol(bb.x,nw,bb.w) Or ol(b.x,bb.x,nw) If ol(bb.y,ny,bb.h) fx=bb.x-b.w If ol(bb.y,nh,bb.h) fx=bb.x-b.w If ol(ny,bb.y,nh) fx=bb.x-b.w If ol(ny,bb.h,nh) fx=bb.x-b.w If bb.y=b.y And b.h=bb.h fx=bb.x-b.w End If End If If fx<0 If ol(bb.x,nx,bb.w) Or ol(nx,bb.w,b.w) If ol(bb.y,ny,bb.h) fx=bb.w-b.x If ol(bb.y,nh,bb.h) fx=bb.w-b.x If ol(ny,bb.y,nh) fx=bb.w-b.x If ol(ny,bb.h,nh) fx=bb.w-b.x If bb.y=b.y And b.h=bb.h fx=bb.w-b.x End If End If If fy>0 If ol(bb.y,nh,bb.h) Or ol(b.y,bb.y,nh) If ol(bb.x,nx,bb.w) fy=bb.y-b.h If ol(bb.x,nw,bb.w) fy=bb.y-b.h If ol(nx,bb.x,nw) fy=bb.y-b.h If ol(nx,bb.w,nw) fy=bb.y-b.h If bb.x=b.x And b.w=bb.w fy=bb.y-b.h End If End If If fy<0 If ol(bb.y,ny,bb.h) Or ol(ny,bb.h,b.h) If ol(bb.x,nx,bb.w) fy=bb.h-b.y If ol(bb.x,nw,bb.w) fy=bb.h-b.y If ol(nx,bb.x,nw) fy=bb.h-b.y If ol(nx,bb.w,nw) fy=bb.h-b.y If bb.x=b.x And b.w=bb.w fy=bb.h-b.y End If End If Next b.x=b.x+fx b.y=b.y+fy b.w=b.w+fx b.h=b.h+fy End Function Graphics 800,600 add_body(410,160,20,240) add_body(50,70,20,140) add_body(50,210,20,140) add_body(230,290,340,20) add_body(130,150,20,100) add_body(280,170,120,20) player=add_body(310,260,20,40) Repeat If KeyHit(KEY_escape) Or AppTerminate() End shift=KeyDown(key_lshift)*200 If KeyDown(key_left) move_body player,-2-shift,0 If KeyDown(key_right) move_body player,2+shift,0 If KeyDown(key_up) move_body player,0,-2-shift If KeyDown(key_down) move_body player,0,2+shift Cls render_bodies Flip 1 Forever Here's compiled EXE, arrows-for move, shift - some speedup movable body (check swept collisions) aabb_collisions.rar
  4. HAHAHA post title is cool! HAHAHAHAHA :D :D
  5. Thank Pixel, now porting it to LUA. It will be very funny!
  6. Your pathfinding looking better But mine - for 2.41 :D
  7. I don't know how your NPCs are walking. My first idea was a waypoints - and i maked it for LUA, my NPC can walk in Editor, but as like on rails. So i spended some time to write this simple mesh pathfinding. Now it on b3d, i'm planing to some update it and port in Leadwerks Editor. To set start-finish nodes use mouse right\left buttons. To see debug lines hold space button. navmesh_basics.rar
  8. Almost all in BMax is * C++ TPickInfo * p=new TPickInfo; p->a=1; BMax local p:Tpickinfo=new Tpickinfo p.a=1
  9. Try to send 2 messages SendEntityMessage(src , "Jump") SendEntityMessage(src , "die") Are they hapenning each other, or last only?
  10. Disable debug mode, and antivirus - compile will be fast, and font will be loads fast.
  11. Aily

    #include?

    The idea is simple: I want to make one lua class to control NPC for example. Now i have one NPC, lets call it JOE.gmf JOE have script JOE.lua, with architecture as all other LUA scripts in Leadwerks. JOE.lua have many lines of code, and many parameters. Now i add new NPC, let's call it MAX.gmf MAX have same code, but another parameters. May be MAX can shot. I copy now JOE.lua to MAX.lua, and ajust parameters. All cool, JOE and MAX walking in world. BUT!!! I see that them stacking in each other then close to each other. I need to fix both lua files in same time? I try to do: copy JOE.lua to "scripts\npc.lua" file clear JOE.lua code And put there only require("scripts/npc") And i have error, that classtable is nil. It is normal? Anyone knows how to correct include files?
  12. Aily

    The Last Chapter

    I think after selling it i will post here full source code and media
  13. Aily

    The Last Chapter

    No, it's in my game SDK only. Don't want to make pack for one level. Just write here about some progress. He-he, five more to go!
  14. Aily

    The Last Chapter

    Josh maked same in LUA scripts. So better was to do all game in LUA. But now - is not possible to move back, and i will finish it in Bmax. My next game will be in LUA.
  15. Aily

    The Last Chapter

    One more level is done
  16. Aily

    The Last Chapter

    http://www.leadwerks.com/werkspace/files/file/278-the-last-chapter/
  17. if entitydistance(mesh,player)<10 pointentity mesh,player
  18. Ha! Funny minigame Need to play it before any FPS shooter, to up skill to strafe. I have feeling, that oildrums is strafe a little with me left-right. Menu fire realy cool
  19. Aily

    The Last Chapter

    And the main program is: Framework leadwerks.engine Import maxgui.drivers Import brl.EventQueue registerabstractpath AppDir AppTitle="The Last Chapter" Include "ini.bmx" Include "app_start.bmx" Include "random.bmx" Include "gra.bmx" Include "wrld.bmx" Include "at.bmx" Include "story.bmx" Include "render.bmx" Include "phy.bmx" Include "pick.bmx" Include "key.bmx" Include "material.bmx" Include "message.bmx" Include "fonts.bmx" Include "game.bmx" Include "bkg.bmx" Include "game_gui.bmx" Include "game_time.bmx" Include "player.bmx" Include "zone.bmx" Include "node.bmx" Include "node_lc_rand.bmx" Include "node_part.bmx" Include "node_enemy.bmx" Include "enemy_segment.bmx" Include "node_coin.bmx" Include "node_dust.bmx" Include "node_post_collect.bmx" Include "node_save.bmx" Include "node_opener.bmx" Include "node_t_platform.bmx" Include "node_enemy_wake_ray.bmx" Include "node_enemy_limits.bmx" Include "node_beton.bmx" Include "node_metal.bmx" Include "node_end_level.bmx" Include "node_fall_die.bmx" Include "node_switch.bmx" Include "node_state_off.bmx" Include "node_key.bmx" Include "node_bullet.bmx" Include "weapon.bmx" Include "node_weapon_fire.bmx" Include "node_garbage.bmx" Include "node_explosion.bmx" Include "later_func.bmx" app_start.run game_time.init gra.init wrld.init fonts.init setshader 0 SetColor vec4(0,0,0,1) DrawRect 0,0,gra.x,gra.y Flip render.init game_gui.init game.init Local in:ini=ini.read_a("game") zone.init in.get("start") phy.init Repeat game.update Forever
  20. Aily

    The Last Chapter

    It may be possible, but not effective without full media - when you can compile and run project. I just can explain the basics First of all i have base type (class), call it "node". Node on create write itself to nodes list. Node have empty (virtual) functions on_init(),on_update(),on_destroy(), etc... Each game object is extends from node, so other game object types are like type node_enemy extends node type node_bullet extends node type node_dust extends node etc... So i don't need to thinking about how each game object type will be "live" in game world, i need only add funtion on_update() to it, and write there all game object need to do. Plus with this all base node type (struct in C) have helper functions like attach_node() - it attaching node object to entity as entity user data set_pos(pos:tvec3) - set body position (but each extended type can override this function and make it own calculations) Like so, i have node_later_func type, wherre on create i can write any function pointer and delay, after wich time run it. BASE NODE IS ROCK! So standart callbacks only getentityuserdata, that always "node", and run it function on_collide() here is my base node code: Type node Global nodes:TList=CreateList() Field name$ 'Field fullname$ Field on_off Field wants_to_die Field touch_sensor Field see_sensor Field body Field mesh Field is_near_player Field player_side Field magnetic Field solid Field end_level Field punch Field blue_key Field green_key Field red_key Field run_later_time# Field need_to_run_later Field current_pos:tvec3 Method hide_show_by_switch() on_off=Not on_off on_hide_show_by_switch() End Method Method on_hide_show_by_switch() 'override End Method Method attach_node(dest=0) If dest=0 dest=body setentityuserdata dest,Self For i=1 To countchildren(dest) child=getchild(dest,i) attach_node child Next End Method Method free() ListRemove nodes,Self End Method Method silent_free() End Method Method hit(pos:tvec3,force) on_hit pos,force End Method Method on_hit(pos:tvec3,force) End Method Method player_collide() on_player_collide() End Method Method on_player_collide() End Method Method read_mesh:node(mesh_name$) mesh=loadmesh("abstract::"+mesh_name+".gmf") Return Self End Method Method set_pos(pos:tvec3) positionentity body,pos,1 End Method Method kill() wants_to_die=True End Method Method check_death() If wants_to_die death End Method Method death() End Method Method build_tree_for_child(mesh_) tmp=createpivot() setentitymatrix tmp,getentitymatrix(mesh_) For i=1 To countsurfaces(mesh_) surf=getsurface(mesh_,i) createbodytree surf,tmp Next entityparent tmp,body For i=1 To countchildren(mesh_) child=getchild(mesh_,i) build_tree_for_child(child) Next End Method Method build_tree() body=createpivot() build_tree_for_child(mesh) End Method Method New() on_off=True ListAddFirst nodes,Self End Method Method init() on_init End Method Method on_init() End Method Method run_later() ' override End Method Method update() on_update is_near_player=False If need_to_run_later If run_later_time<0 run_later need_to_run_later=False Else run_later_time:-appspd() End If End If End Method Method on_update() End Method Method clear() End Method Function update_scene() For n:node=EachIn nodes n.update Next End Function End Type here is bullet node Type node_bullet Extends node Field life_time# Field max_life# Field power Global player_bullet Function init_bullets() player_bullet=loadmesh("abstract::player_bullet.gmf") 'player_bullet=createsphere() 'entitycolor player_bullet,vec4(.8,.5,0,1) rotatemesh player_bullet,vec3(90,90,0) hideentity player_bullet End Function Method on_init() body=createbodybox(1,.8,.5) 'entityparent mesh,body entitytype body,phy.type_player_bullet setbodygravitymode body,0 setbodymass body,.1 sweptcollision body,True setentitycallback body,bullet_to,ENTITYCALLBACK_COLLISION attach_node End Method Method shot(pos:tvec3,dir,force) positionentity body,pos If dir=1 rotateentity body,vec4(0,-90,0) Else rotateentity body,vec4(0,90,0) End If moveentity body,vec3(0,0,1.5) setbodyforce body,vec3(0,0,force),0 End Method Method free_bullet() freeentity mesh freeentity body free End Method Method on_update() life_time:+appspeed() setentitymatrix mesh,getentitymatrix(body) If life_time>max_life free_bullet End If End Method Method destroy_bullet() 'node_weapon_fire.respawn entityposition(body) node_explosion.gen2_at entityposition(body),0 part.coin_hit entityposition(body) 'node_dust.gen_hit_at entityposition(body) 'node_post_collect.gen entityposition(body) setentitycallback body,Null,ENTITYCALLBACK_COLLISION free_bullet End Method End Type And zone on load parse all scene GMF file, select each child name, and make such: Function process_zone(lst:TList) Local n:node For sm:sub_mesh=EachIn lst Select sm.name Case "enemy" n=New node_enemy n.init n.set_pos entityposition(sm.mesh,1) Case "coin" n=New node_coin n.init n.set_pos entityposition(sm.mesh,1) Case "blue_key" n=New node_key n.blue_key=True n.init n.set_pos entityposition(sm.mesh,1) Case "red_key" n=New node_key n.red_key=True n.init n.set_pos entityposition(sm.mesh,1) Case "green_key" n=New node_key n.green_key=True n.init n.set_pos entityposition(sm.mesh,1) Case "player" player.init player.set_pos entityposition(sm.mesh,1) Case "metal" n=New node_metal n.mesh=sm.mesh n.init Case "beton" n=New node_beton n.mesh=sm.mesh n.name=Replace(sm.fullname,"#","") n.init Case "enemy_limit" n=New node_enemy_limits n.mesh=sm.mesh n.init Case "solid" n=New node_beton n.mesh=sm.mesh n.name=Replace(sm.fullname,"#","") n.init Case "on/off" n=New node_switch n.name=sm.fullname n.mesh=sm.mesh n.init Case "on/off/blue" n=New node_switch n.name=sm.fullname n.mesh=sm.mesh n.blue_key=True n.init Case "on/off/green" n=New node_switch n.name=sm.fullname n.mesh=sm.mesh n.green_key=True n.init Case "on/off/red" n=New node_switch n.name=sm.fullname n.mesh=sm.mesh n.red_key=True n.init Case "state_off" node_state_off.add_off_nodes sm.fullname Case "opener" n=New node_opener n.name=Replace(sm.fullname,"#","") n.mesh=sm.mesh n.init Case "t_platform" n=New node_t_platform n.name=Replace(sm.fullname,"#","") n.mesh=sm.mesh n.init Case "inst" sub_child=findchild(mesh,sm.src_name) If sub_child nmesh=copyentity(sub_child) 'entityviewrange nmesh,VIEWRANGE_INFINITE setentitymatrix nmesh,getentitymatrix(sm.mesh) hideentity sm.mesh End If Case "refract" wrld.r nmesh=copyentity(sm.mesh) hideentity sm.mesh wrld.m Case "grass" If Not gra.grass hideentity sm.mesh End Select Next End Function The best thing with Leadwerks is it simplify and quality, but(!!!) many people are forget that its good working with BlitzMax! BlitzMax is much simply, stable, lightweight than any C++, C#, Delphy, or else. METATRON, fortran and C and Delphy much faster than BlitzMax . I droped to writing my script system for game, because BlitzMax enough simple as scripting language, so when i need new game object (flying enemy for example), i need only to crete new node_flying_enemy, write it on_init() and on_update() functions, and put it to zone loading "select....end select" condition All other things are will be maked. I'm using many timers in each object, and each timer extends from base node too. It's very handy at the end, when each game object is same. I don't undarstanding, why Josh not maked such handy void node base class, that call on_update each time before update world. P.S. Thanks to Arbuz for learning OOP basics P.P.S. And ActionScript architecture with change function pointers on-the-fly
  21. Aily

    Emitter

    You can, but they sprites will be turned to directional light, not to camera such funny bug.
  22. Aily

    Emitter

    setworld maybe?
  23. Well done Alien! Looks as complete game. But at my point of view postprocessing textures is very dark and dirty, without collor correction looks much better.
×
×
  • Create New...