BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Mappy and Nsprite at same time"
, by gustav
You can make a tilemap and work with fast sprites with some coding problems. I prefer to use pre-made libs and tools like Mappy an Nsprite, after all they're COMPATIBLE xD
Code
NOTES: The code only work with the tilemap, libs, and nsprite.bmp (included in the original libraries). Nsprite homepage: http://www.nuloen.com Mappy homepage: http://www.tilemap.co.uk The code is one Mappy bbasic example with the inclusion of the Nsprite lib, for easy collision detection and fast rotations,etc. The rar with sourcecode and libraries: http://jamayam.en.telepolis.com/Mappy & Nsprite.rar The code: ;MD3TEST original mappy example mixed with NSPRITE functions ;Uses 3d, tile-maps and fast sprites ;This demosntrates that these 2 libraries are COMPATIBLE xD Include "mappybb.bb" Include "nSprite.bb" Const MSPERFRAME = 15 ;speed of game, 10 = 100 fps, 15 = 75fps, 20 = 50 fps etc Const scrw = 640 Const scrh = 480 Global px = 0 Global py = 0 Global smooth = 1 deg#=0.5 a=0 Graphics3D scrw, scrh, 16, 2 ;To use 3D, just set Graphics3D nS_ClearWorld() cam = CreateCamera () nS_Initialize() CameraClsMode cam, 0, 1 ;Important, this line preserves the tilemap clight = CreateLight () MoveEntity clight, -10, 10, -10 cube = CreateCube () MoveEntity cube, 0, 0, 8 EntityColor cube, 0, 128, 0 ;EntityAlpha cube, 0.75 ;By using alpha, you can affect the background cube2 = CreateCube () MoveEntity cube2, -5, 0, 8 EntityColor cube2, 128, 0, 0 EntityAlpha cube2, 0.75 cube3 = CreateCube () MoveEntity cube3, 5, 0, 8 EntityColor cube3, 0, 0, 128 EntityAlpha cube3, 0.75 light=CreateLight( 3 ) MoveEntity light,0,0,-10 LightColor light,255,255,0 LightConeAngles light,0,10 LightRange light,75 AmbientLight 0,0,0 sprNSprite = nS_LoadImage("nsprite.bmp") sprjulio=LoadImage("nsprite.bmp") nS_MidHandle(sprNSprite)MapLoad ("test2.FMP") MapInitAnims () SetBuffer BackBuffer() time=MilliSecs() While Not KeyHit(1) n_time=MilliSecs() elapsed = MSPERFRAME cnt=1 If cnt>0 For k=1 To cnt ;Next anim frames MapUpdateAnims () py = py + pdir px = px + pdir If (px >= (mapwidth*mapblockwidth-scrw)) pdir = -2 If (px <= 0) pdir = 2 TurnEntity cube, 1, 1, 1 TurnEntity cube2, 1, -1, 1 TurnEntity cube3, 1, 1, -1 nS_RotateImage(sprNSprite, 2);Rotating logo code nS_ResizeImage(sprNSprite, deg, deg, True) nS_DrawImage(sprNSprite, 320, 240) Next ;Draw BG at map coords px, py and at screen pos 0, 0 at size scrw, scrh MapDrawBG (px, py, 0, 0, scrw, scrh) DrawImage sprjulio,(100*Sin(py))+130,150 ;Logo between BG and layer 0 ;Draw FG layer 0 MapDrawFG (px, py, 0, 0, scrw, scrh, 0) RenderWorld Flip If a=0 Then deg#=Float (deg+0.05) If deg>4 Then a=1 EndIf If a=1 Then deg#=Float (deg-0.05) If deg<0.5 Then a=0 EndIf EndIf Wend MapFreeMem () EndGraphics End
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations