I'm a new user and I need some information

Advanced game related topics
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

I'm a new user and I need some information

Post by ale870 »

Hello,

I'm a new user, I just bought PureBasic.
Since I need to make a game, I wish some "objective" information to better understand if Pure Basic is the right tool, or if is better that I look for other programs.
I tried to find these information in the forum and in the web, but it is hard to get definitive answers (I hope you could help me).
First of all, I want to say that I'm a programmer. I need to create a game with 2D top-view (not isometric, but with camera seen on top).
Basically I want to make a 2D application (with editor, and modding features, and implementing "newLisp - http://newlisp.org" as scripting language), but using 3D sprites (to better move, rotate and render the vehicles and other things).
Obviously, I know that something can be done, but I'm alone, so I hope I can do them without too much workload (I need some pre-made functionalities, just to speed-up my job).
So...

1) Can I create 2D tiled backgrounds with sprites in 3D?
2) Can I implement a physic engine without too much workload (newton physics? ODE? or... ?)
3) Can I realize viewports (I need to get more "views" of the game in the same screen. For me a view is a "window" inside the game. Two views are like two camera working at the same time).
4) Can I work on a sprite canvas (or other images) in real time (to apply some special effects)?
5) Can I insert C code in the source code (like one do with assembler)?
6) Can I apply light effects in real time (like day-cycle)? Yes I know I'm talking about 2D game, but some nice light effects could be applied also.
7) When I load an image, does it automatically go in the video card RAM, or I can manage that process manually (e.g.: I want to load some sprites in background, with a thread, then I "send" only needed images to the video card, after a CPU preprocessing and only when needed, just to avoid to fill video card memory).
8) Which direct X version use PB? (DX3? DX7? DX8? DX9?)

I know I made many questions, I'm sorry, :oops: , but I really need such answers in order to avoid to spend many months with the wrong tool.

I found possible alternatives, but PB seems very good:
1) GLBasic (seems more game-oriented, but...).
2) Blitzmax (but its development seems blocked, only updates are made).
3) I use Delphi in my official job, but I cannot find any good, updated library to make the games.
4) Play Basic seems not really compiled (I made some tests and the p-code seems slow).

Thank you to everyone for your patience!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

1) Can I create 2D tiled backgrounds with sprites in 3D?

Sure! Same thing has normal sprites!

2) Can I implement a physic engine without too much workload (newton physics? ODE? or... ?)

There is a wrapper in this forum for the chipmunk 2d physics, so yes!

3) Can I realize viewports (I need to get more "views" of the game in the same screen. For me a view is a "window" inside the game. Two views are like two camera working at the same time).

Yes, but you need to program that...

4) Can I work on a sprite canvas (or other images) in real time (to apply some special effects)?

Yes, StartDrawing(SpriteOutput()) ;)
It's slow ... But you can use the memory image buffer directly too with peek() and poke().

5) Can I insert C code in the source code (like one do with assembler)?

No, assembler you can, C no, but you can build a DLL with those C functions you need, and call them where needed in the PB code.

6) Can I apply light effects in real time (like day-cycle)? Yes I know I'm talking about 2D game, but some nice light effects could be applied also.

Yes, it's possible, again you must write that routine yourself...

7) When I load an image, does it automatically go in the video card RAM, or I can manage that process manually (e.g.: I want to load some sprites in background, with a thread, then I "send" only needed images to the video card, after a CPU preprocessing and only when needed, just to avoid to fill video card memory).


You can choose when loading, by default the video card memory is used, but in can set it to RAM.

Cool Which direct X version use PB? (DX3? DX7? DX8? DX9?)

PB uses DX7, but soon (Version 4.30) you can a bug free DX9 subsystem.
(DX9 is already present in 4.20, but is has some bugs)
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you for your quick reply!
You helped me so much!

1) I'm not talking about "sprite3d", and I'm not talking about Ogre... (real powerful 3d engine). How can I do that?

3) About Viewports, what do you mean when you say "I need to program them"? Can I redirect a rendering area to a specific viewport like a window? I think I will manage refresh by myself (like any other game!) but I hope PB manage clipping area, relative coordinates, etc...

4() About canvas management... what do you mean when you say that the process is "slow"? Is it better working with peek/poke? Do you think my loops with "poke" could be faster than internal image functions? Can you give me some hints about that?

New-1) One new question: I noticed PB implements threading features: does it uses multicore / multiprocessor when they are in the computer?

*EDIT*
Sorry, one thing more: do you think PB is a good tool to work for 2D games or it should be better other tools like GLBasic (but I do not know it).

Thank you again!


Thank you again for your help!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

1) I'm not talking about "sprite3d", and I'm not talking about Ogre... (real powerful 3d engine). How can I do that?

Old school way ;)
Image you have an 800x600 screen
Let's say you display 16 x 16 tiles from the map at a time

Code: Select all

For x=1 to 16 
 For y=1 to 16
  TileNb.l=Map(x,y)
  DrawSprite(TileNb, x*TileSizeX,y*TileSizeY)
 Next
Next

3) About Viewports, what do you mean when you say "I need to program them"? Can I redirect a rendering area to a specific viewport like a window? I think I will manage refresh by myself (like any other game!) but I hope PB manage clipping area, relative coordinates, etc...

You have to do it yourself... Use the same routine that draws the screen map to draw what you want to show on a sprite, then display that sprite on the main screen...


4() About canvas management... what do you mean when you say that the process is "slow"? Is it better working with peek/poke? Do you think my loops with "poke" could be faster than internal image functions? Can you give me some hints about that?

Sprite to Sprite is fast, but if you use plot() it's very slow.
It all depends on what you want to make.

New-1) One new question: I noticed PB implements threading features: does it uses multicore / multiprocessor when they are in the computer?

Yes you can use threads, but i don't think PB assigns directly each thread to a core, you must do that yourself.

*EDIT*
Sorry, one thing more: do you think PB is a good tool to work for 2D games or it should be better other tools like GLBasic (but I do not know it).

You can do pretty much anything with purebasic ;)
Take a look here:

http://www.purebasic.fr/english/viewtopic.php?t=32481
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you again!
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

1) Can I create 2D tiled backgrounds with sprites in 3D?
I'm not talking about "sprite3d", and I'm not talking about Ogre...
when you mean neither Sprite3D nor OGRE, what do you mean?

3) + 4)
you can redirect drawing output on a sprite using
StartDrawing(SpriteOutput(SpriteNr))
you can redirect screenoutput like DisplaySprite and such using
UseBuffer(SpriteNr)

...

Example:
Simple Tile-Engine

Image
copy this picture, cut it into 8 16x16 tiles, save them seperately as 001.bmp to 008.bmp

this code shows a tileengine for 16x16 tiles on a fullscreen with mouse-position check.

Code: Select all

InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(800,600,32,"Tiledemo")

For n=1 To 8
  LoadSprite( 100+n, Right("00"+Str(n),3)+".bmp")
Next
CreateSprite(109,16,16)
StartDrawing(SpriteOutput(109))
  Box(0,0,16,16,$808000)
  For n=0 To 2
    Line(n-1,  0, 16, 16,$FFFF00)
    Line(n-1, 15, 16,-16,$FFFF00)
  Next
StopDrawing()

Dim Map(1023,1023)

For n=0 To 1023
  For t=0 To 1023
    Map(n,t) = Random(7)+1
  Next
Next

MouseLocate(400,300)
FineStep = 4
Repeat
  ExamineKeyboard()
  ExamineMouse()
  MauX = MouseX() : MauY = MouseY()
  ClearScreen(0)

  If KeyboardPushed(#PB_Key_Left) Or MauX < 8
    FineX-FineStep
    If FineX < 0
      FineX = 16-FineStep
      MapX-1
      If MapX < 0
        MapX = 0
        FineX = 0
      EndIf
    EndIf
  EndIf
  If KeyboardPushed(#PB_Key_Right) Or MauX > 792
    FineX+FineStep
    If FineX > 16-FineStep
      FineX = 0
      MapX+1
      If MapX > 1023-50
        MapX = 1023-50
        FineX = 16-FineStep
      EndIf
    EndIf
  EndIf
  If KeyboardPushed(#PB_Key_Up) Or MauY < 8
    FineY-FineStep
    If FineY < 0
      FineY = 16-FineStep
      MapY-1
      If MapY < 0
        MapY = 0
        FineY = 0
      EndIf
    EndIf
  EndIf
  If KeyboardPushed(#PB_Key_Down) Or MauY > 592
    FineY+FineStep
    If FineY > 16-FineStep
      FineY = 0
      MapY+1
      If MapY > 1023-38
        MapY = 1023-38
        FineY = 16-FineStep
      EndIf
    EndIf
  EndIf

;***********************************
;*** wo ist die maus?
ActTileX = (MauX+FineX) / 16 + MapX
ActTileY = (MauY+FineY) / 16 + MapY

; um zu beweisen, dass es funktioniert,
; ersetze ich direkt im Array das Tile
; über dem sich die Maus befindet.
Buff = Map(ActTileX,ActTileY)   ; Rückspeichern
Map(ActTileX,ActTileY) = 9      ; ne 9 reinschreiben
;***********************************
;*** Tile Engine
  For SY=0 To 38
    For SX = 0 To 50
      DisplaySprite(100+Map(MapX+SX,MapY+SY), 16*SX - FineX , 16*SY - FineY )
    Next
  Next
;***********************************
Map(ActTileX,ActTileY) = Buff   ; den alten Wert wiederherstellen.


  StartDrawing(ScreenOutput())
    DrawingMode(1)
    DrawText( 8, 8,"X: "+Right("000"+Str(ActTileX),4))
    DrawText( 8,24,"X: "+Right("000"+Str(ActTileY),4))
    For n=0 To 2
      Line(MauX+n,MauY  , 8,32,$00FFFF)
      Line(MauX  ,MauY+n,32, 8,$00FFFF)
    Next
  StopDrawing()

  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
oh... and have a nice day.
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 576
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

3) I use Delphi in my official job, but I cannot find any good, updated library to make the games.
Jedi-SDL?
Andorra?
Allegro-Pas?
DGL?

www.pascalgamedevelopment.com
cheers,

bembulak
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you! Example is really useful!

About Delphi: I found some libraries but they seems to have some drawbacks for commercial purposes: not mature development stage, missing some important features for a rapid development (more suited for low level access, and related to large teams), created by very young boys (my doubts for the future of the library...), etc...

I think Delphi / free Pascal / Lazarus, even if they are fast, they are not used so much, even if Delphi/FreePascal is easier than C++ but with similar performance and global features.

Thank you!
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

If you are only using 3D sprites in a 2D game, I'd recommend using:

- Purebasic native 2D commands (works really nice)
- Blitz3D SDK (the 2D commands are very stable and fast)
- HGE (with neotoma's new wrapper)

Since you're a new user, you'll discover that Purebasic has many choices when it comes to game programming. All of them are integrated really well in PB.

It's nice to see the ports/wrappers that are being made recently like the HGE Wrapper and PureGDK and the next PB version will have an updated OGRE engine. If you haven't seen yet what OGRE is capable, look here:

http://www.ogre3d.org/index.php?set_alb ... _album.php
Proud registered Purebasic user.
Because programming should be fun.
untune
User
User
Posts: 56
Joined: Sun Jul 06, 2008 10:07 pm
Location: Bolton, UK

Post by untune »

I'm enjoying playing around with the hge engine, it's very stable and has a big user base, and since it's now open source work will continue on it... some people are already porting it to DX9 etc... I wish I understood C then it could be maintained for the PB community...

I think you should have a look at that as it offers some great features for hardware-accelerated 2d game development... and the PB HGE wrapper has some box2d physics implemented which is very cool :D
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Indeed. There are some extra procedures in the HGE wrapper like converting a PB image into a HGE texture and some other stuff like XML splines which are very welcome. :D
Proud registered Purebasic user.
Because programming should be fun.
ale870
Enthusiast
Enthusiast
Posts: 180
Joined: Wed Jul 09, 2008 7:02 am
Contact:

Post by ale870 »

Thank you!

I just bought it and now I'm studying to realize my game! :D
Post Reply