Hi guys,
I remember some people tried to port some game code from win to osx without success in the past. One was the Lost Labyrinth by Brujah. How much the OSX version is up to date nowadays in general? How robust is it compare to the windows version? How hard it could be to port a 2D windows game to OSX? Did anybody compile Waponez II (for example) by any chance on any of the OSX platforms (intel or ppc)? I know PB on OSX is in progress but it would be nice to hear about it's current status, experiences, and maybe some "official statements" from the creators.
Thanks!
Cross Platform 2D Game Development Win-OSX?
Cross Platform 2D Game Development Win-OSX?
Last edited by Krix on Tue Sep 08, 2009 7:47 am, edited 1 time in total.
Lucky you, I got my MacBook just a week ago and I'm still in the middle of discovering OS X. So far I must say the overall experience with Mac is great and just for fun I really did try and compile some applications and games with PureBasic. I don't know the past, but I did not need to make big changes to get everything to work, not sure of Waponez though (might as well try it out later). In terms of maturity versus other versions of PureBasic, it does feel as mature as the Windows and Linux versions (of which I use both actively).
However, consider me as a newbie in the Mac realm, maybe some of the pros can shed more light to this. As it is however, there do not seem to be much problems with the Mac version, at least with my Intel MacBook (not sure of PowerPC).
However, consider me as a newbie in the Mac realm, maybe some of the pros can shed more light to this. As it is however, there do not seem to be much problems with the Mac version, at least with my Intel MacBook (not sure of PowerPC).
Ok, after a kick in the butt by Krix, I dug up the Waponez II source after install Purebasic on a vmware virtual machine on my Mac and tried to compile it with Purebasic 4.4B2. My mac is a Macbook Pro from 2 years ago almost to the day, intel processor and running Snow Leopard.
First it complained about the Joystick. Whoops... erased all the lines referencing the joystick. Next it compiled and ran but crashed into the debugger - it couldn't find any of the graphics files. Noticed that the Path$ variable was using a \ instead of a / so changed that to [Path$ = "Data/"] and recompiled it...
It runs just fine.
Purebasic rocks!
Code attached:
First it complained about the Joystick. Whoops... erased all the lines referencing the joystick. Next it compiled and ran but crashed into the debugger - it couldn't find any of the graphics files. Noticed that the Path$ variable was using a \ instead of a / so changed that to [Path$ = "Data/"] and recompiled it...
It runs just fine.
Code attached:
Code: Select all
;
; **************
; *
; Waponez II **********************************************
; *
; Origninal Waponez is from NC Gamez ! Check it on Aminet... *
; *
; *****************************************************************
;
; NOTE: This file doesn't compile with the demo version !
;
;
; Initialization of all the used ressources
;
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't open DirectX 7 or later", 0)
End
EndIf
If InitSound() = 0
MessageRequester("Error", "Can't open DirectX 7 Or Sound Card is not present", 0)
End
EndIf
;
; Our bullet structure, which will be used by the linkedlist Bullet()
;
Structure Bullet
x.w
y.w
Width.w
Height.w
Image.w
SpeedX.w
SpeedY.w
EndStructure
Global NewList Bullet.Bullet()
Structure Explosion
x.w
y.w
State.w
Delay.w
EndStructure
Global NewList Explosion.Explosion()
Structure Alien
x.w
y.w
Width.w
Height.w
Speed.w
StartImage.w
EndImage.w
ImageDelay.w
NextImageDelay.w
ActualImage.w
Armor.w
EndStructure
Global NewList Aliens.Alien()
Procedure AddBullet(Sprite, x, y, SpeedX, SpeedY)
AddElement(Bullet())
Bullet()\x = x
Bullet()\y = y
Bullet()\Width = SpriteWidth(Sprite)
Bullet()\Height = SpriteHeight(Sprite)
Bullet()\Image = Sprite
Bullet()\SpeedX = SpeedX
Bullet()\SpeedY = SpeedY
EndProcedure
MessageRequester("Welcome !", "It's the first game done with PureBasic x86 !"+Chr(10)+"Use the Arrows + Space To blast them all !!"+Chr(10)+Chr(10)+"Enjoy :-) !", 0)
;
; Now, open a 640*480 - 16 bits colours screen
;
Path$ = "Data/"
; SetRefreshRate(60)
If OpenScreen(640, 480, 16, "Waponez II")
PlayerSpeedX = 6
PlayerSpeedY = 6
BulletSpeed = 10
;
; Load the sound effects
;
LoadSound(0, Path$+"Lazer.wav")
LoadSound(2, Path$+"Explosion.wav")
;
; Load the 3 player sprites
;
LoadSprite(3, Path$+"Player_1.bmp", 0)
LoadSprite(0, Path$+"Player_2.bmp", 0)
LoadSprite(2, Path$+"Player_3.bmp", 0)
;
; Load the bullets
;
LoadSprite( 4, Path$+"Bullet_1.bmp", 0)
LoadSprite( 6, Path$+"Bullet_Right.bmp", 0)
LoadSprite( 7, Path$+"Bullet_Left.bmp", 0)
LoadSprite( 8, Path$+"Bullet_Diag1.bmp", 0)
LoadSprite( 9, Path$+"Bullet_Diag2.bmp", 0)
LoadSprite(55, Path$+"Bullet_Bottom.bmp", 0)
;
; Sprite 10 to 15 reserved for the rotating animated alien..
;
For k=0 To 5
LoadSprite(k+10, Path$+"Ennemy_3_"+Str(k+1)+".bmp", 0)
Next
;
; Sprite 20 to 30 reserved for the explosions...
;
For k=0 To 7
LoadSprite(k+20, Path$+"Explosion_"+Str(k+1)+".bmp", 0)
Next
;
; Load the background sprite
;
LoadSprite(20, Path$+"Back_3.bmp", 0)
;
PlayerWidth = SpriteWidth(3)
PlayerHeight = SpriteHeight(3)
PlayerX = 300
PlayerY = 400
Repeat
FlipBuffers() ; This should be always in the loop, the events are handle by this functions
If IsScreenActive() ; Check if is active or not (ALT+TAB symptom :)
db = 1-db
; Draw the background (an unified one...)
For BackX=0 To 640 Step 32
For BackY=-32 To 480 Step 32
DisplaySprite(20, BackX, BackY+ScrollY)
Next
Next
Gosub CheckCollisions
Gosub MovePlayers
Gosub DisplayBullets
Gosub NewAlienWave
Gosub DisplayAliens
Gosub DisplayExplosions
If BulletDelay > 0
BulletDelay-1
EndIf
If ScrollDelay = 0
ScrollY+1
ScrollDelay = 0
Else
ScrollDelay-1
EndIf
If ScrollY>31
ScrollY = 0
EndIf
Else
; The screen is no more active but our game multitask friendly, so we stop the sounds and
; add a delay to not eat the whole CPU. Smart hey ? :)
StopSound(-1)
Delay(20)
EndIf
Until KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Waponez II", "Can't open a 640*480 8 bit screen !", 0)
EndIf
End
MovePlayers:
Fire = 0
PlayerImage = 3 ; Non-moving player image
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
PlayerX-PlayerSpeedX
PlayerImage = 2 ; Left moving player image
EndIf
If KeyboardPushed(#PB_Key_Right)
PlayerX+PlayerSpeedX
PlayerImage = 0 ; Right moving player image
EndIf
If KeyboardPushed(#PB_Key_Up)
PlayerY-PlayerSpeedY
EndIf
If KeyboardPushed(#PB_Key_Down)
PlayerY+PlayerSpeedY
EndIf
If PlayerX < 0 : PlayerX = 0 : EndIf
If PlayerY < 0 : PlayerY = 0 : EndIf
If PlayerX > 640-PlayerWidth : PlayerX = 640-PlayerWidth : EndIf
If PlayerY > 480-PlayerHeight : PlayerY = 480-PlayerHeight : EndIf
If Dead = 1
AddElement(Explosion())
Explosion()\x = PlayerX
Explosion()\y = PlayerY
Dead = 0
Else
If DeadDelay>0
DeadDelay-1
If db=1
If DeadDelay < 200
DisplayTransparentSprite(PlayerImage, PlayerX, PlayerY)
EndIf
EndIf
Else
DisplayTransparentSprite(PlayerImage, PlayerX, PlayerY)
EndIf
EndIf
If KeyboardPushed(#PB_Key_Space) Or Fire
If BulletDelay = 0
If DeadDelay < 100
BulletDelay = 10
; AddBullet() syntax: (#Sprite, x, y, SpeedX, SpeedY)
;
AddBullet(4, PlayerX+5 , PlayerY-10, 0 , -BulletSpeed) ; Front bullet (Double bullet sprite)
AddBullet(6, PlayerX+45, PlayerY+6 , BulletSpeed, 0) ; Right side bullet
AddBullet(7, PlayerX-11, PlayerY+6 , -BulletSpeed, 0) ; Left side bullet
AddBullet(8, PlayerX+45, PlayerY-6 , BulletSpeed, -BulletSpeed) ; Front-Right bullet
AddBullet(9, PlayerX-11, PlayerY-6 , -BulletSpeed, -BulletSpeed) ; Front-Left bullet
AddBullet(55,PlayerX+20, PlayerY+45, 0 , BulletSpeed) ; Rear bullet
PlaySound(0, 0) ; Play the 'pffffiiiouuu' lazer like sound
EndIf
EndIf
EndIf
Return
DisplayBullets:
ResetList(Bullet())
While NextElement(Bullet()) ; Process all the bullet actualy displayed on the screen
If Bullet()\y < 0 ; If a bullet is now out of the screen, simply delete it..
DeleteElement(Bullet())
Else
If Bullet()\x < 0 ; If a bullet is now out of the screen, simply delete it..
DeleteElement(Bullet())
Else
If Bullet()\x > 640-Bullet()\Width
DeleteElement(Bullet())
Else
If Bullet()\y > 480
DeleteElement(Bullet())
Else
DisplayTransparentSprite(Bullet()\Image, Bullet()\x, Bullet()\y) ; Display the bullet..
Bullet()\y + Bullet()\SpeedY
Bullet()\x + Bullet()\SpeedX
EndIf
EndIf
EndIf
EndIf
Wend
Return
NewAlienWave:
If AlienDelay = 0
AddElement(Aliens())
If Boss = 1
Aliens()\x = 100
Aliens()\y = -16
Aliens()\Width = SpriteWidth(50)
Aliens()\Height = SpriteHeight(50)
Aliens()\Speed = 2
Aliens()\StartImage = 50
Aliens()\EndImage = 50
Aliens()\ImageDelay = 1
Aliens()\NextImageDelay = 1
Aliens()\ActualImage = 50
Aliens()\Armor = 20
AlienDelay = 80
Else
Aliens()\x = Random(600)
Aliens()\y = -32
Aliens()\Width = SpriteWidth(10)
Aliens()\Height = SpriteHeight(10)
Aliens()\Speed = 3
Aliens()\StartImage = 10
Aliens()\EndImage = 15
Aliens()\ImageDelay = 4
Aliens()\NextImageDelay = Aliens()\ImageDelay
Aliens()\ActualImage = 10
Aliens()\Armor = 5
AlienDelay = Random(20)
EndIf
Else
AlienDelay-1
EndIf
Return
DisplayAliens:
ResetList(Aliens())
While NextElement(Aliens())
DisplayTransparentSprite(Aliens()\ActualImage, Aliens()\x, Aliens()\y)
Aliens()\y + Aliens()\Speed
If Aliens()\NextImageDelay = 0
Aliens()\ActualImage+1
If Aliens()\ActualImage > Aliens()\EndImage
Aliens()\ActualImage = Aliens()\StartImage
EndIf
Aliens()\NextImageDelay = Aliens()\ImageDelay
Else
Aliens()\NextImageDelay-1
EndIf
If Aliens()\Armor <= 0
AddElement(Explosion())
Explosion()\x = Aliens()\x
Explosion()\y = Aliens()\y
Score+20
DeleteElement(Aliens())
Else
If Aliens()\y > 480
DeleteElement(Aliens())
EndIf
EndIf
Wend
Return
CheckCollisions:
ResetList(Aliens())
While NextElement(Aliens())
ResetList(Bullet())
While NextElement(Bullet())
If SpritePixelCollision(Bullet()\Image, Bullet()\x, Bullet()\y, Aliens()\ActualImage, Aliens()\x, Aliens()\y)
Aliens()\Armor-1
DeleteElement(Bullet())
EndIf
Wend
If DeadDelay = 0 ; No more invincible...
If SpritePixelCollision(PlayerImage, PlayerX, PlayerY, Aliens()\ActualImage, Aliens()\x, Aliens()\y)
Dead = 1
DeadDelay = 300
AddElement(Explosion())
Explosion()\x = Aliens()\x
Explosion()\y = Aliens()\y
DeleteElement(Aliens())
EndIf
EndIf
Wend
Return
; DisplayExplosion:
; -----------------
;
; Once an explosion has been declared (an aliens has been destroyed or the player...), it will be
; displayed inside this routine. The object remains until the end of the explosion (all the pictures
; have been displayed). Then the object is removed with DeleteElement().
;
DisplayExplosions:
ResetList(Explosion())
While NextElement(Explosion()) ; Take the explosions objects, one by one.
; For each object, display the current explosion image (called state here)
DisplayTransparentSprite(Explosion()\State+20, Explosion()\x, Explosion()\y)
If Explosion()\Delay = 0
If Explosion()\State = 0 ; Play the sound only at the explosion start.
PlaySound(2, 0)
EndIf
If Explosion()\State < 7
Explosion()\State+1
Explosion()\Delay = 3
Else
DeleteElement(Explosion())
EndIf
Else
Explosion()\Delay-1
EndIf
Wend
Return
-
jamirokwai
- Enthusiast

- Posts: 799
- Joined: Tue May 20, 2008 2:12 am
- Location: Cologne, Germany
- Contact:
Re: Cross Platform 2D Game Development Win-OSX?
Hi Krix,Krix wrote:Hi guys,
I remember some people tried to port some game code from win to osx without success in the past. One was the Lost Labyrinth by Brujah. How much the OSX version is up to date nowadays in general? How robust is it compare to the windows version? How hard it could be to port a 2D windows game to OSX? Did anybody compile Waponez II (for example) by any chance on any of the OSX platforms (intel or ppc)? I know PB on OSX is in progress but it would be nice to hear about it's current status, experiences, and maybe some "official statements" from the creators.
Thanks!
can't tell (yet) from the gamers point of view. But I am coding my Reisekostenrechner - GUI, not fullscreen - on Mac OS X x86. After testing I copy the whole code into a VirtualBox with Windows XP and PureBasic. Compiling is a matter of seconds only.
I suppose I needed to change code for Windows in about 5 or 6 procedures only. Mainly because of the different size of chars when printing, and some differences in folder-handling. I hope to compile to a Linux-version soon without any hassle
Overall I am very satisfied with PureBasic, and my first customer (tada!) working with the Windows XP version, is also.
Links (all German)
http://www.quadworks.de/?artikel=2009-09-01/00-20-00
http://www.quadworks.de/?artikel=2009-08-10/12-29-00
Since these tools are not so big in download, you may have a look at the differences between Windows and Mac OS X. They are only cosmetical...
---
I also tried some of the examples from around the forum. Most of them will compile and work fine with PB 4.40b2, x86 (besides the missing printer-lib in 4.40b2). I would guess, PureBasic for Mac in it's 4.40 incarnation will be the easiest language to learn and use when cross-coding for Mac, Windows, and Linux.
Regards,
JamiroKwai
JamiroKwai
