General Discussions

Blitz Program needed for testing – firemaker103

firemaker103

Member

Posts: 643
From:
Registered: 07-13-2005
Hello all! It's been two weeks since I've gotten internet. Did you miss me?

Anyway, now that that is out of the way, I have a request. I need the source to one of your Blitz Basic games. Hang with me here for a second.

See, I'm testing a sort of compression/could-be-installer-ish type program I developed. Basically it takes the media files and converts them to hex data statements in your Blitz Basic file. You will need to manually add some more code to make it work, though. Once you can compile that, all you need to distribute for your game is that EXE file. To go further, you can compress it with UPX too! At run-time, the newly EXE extracts the data statements to their respective binary files. Then you can load those up and simply delete them so no one can access them(another "feature" in the program).

Full games can be distributed like this in less then a megabyte!

All I need from you guys is the source of one of your Blitz games. Make it have some big media files(BMPs and WAVs) preferably less then 4 in total. Make sure it is a game you can trust me with!

Thanks,
FM

Edit: After re-reading that, I suppose didn't make a lot of sense. I'm bad at explaining things.

------------------
"Be nice to the nerds because later on, you'll be working for them" - Bill Gates

[This message has been edited by firemaker103 (edited June 04, 2006).]

dartsman

Member

Posts: 484
From: Queensland, Australia
Registered: 03-16-2006
I don't see why you don't just setup some test/dummy projects with blitz yourself??

I haven't used blitz and never will, but I would presume that you could easily setup your own project and then just test using that. And quiet easily create more test/dummy projects... they wouldn't technically have to work either, its not like your testing that the game runs... more that your just testing that all resources are compressed write and that the game exe wasn't messed with...

Hmmm... I could be wrong though, as I have never used blitz, and it might be different to what I'm thinking of...

------------------
"But it is God who judges: He brings one down, he exalts another." - Psalm 75:7

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Here is one of my longish projects, not too heavy on media, but it has both images and sound. Btw do you want me to give you the media or just the source? if you need the media as well just reply and ill supply; hey I rhyme all the time =D!

choice = Input("Windowed? 1 = true 2 = false ")

If choice = 2 Then
Graphics 800,600,32,1
Else
Graphics 800,600,32,2
EndIf
;1 = positional update
;2 = bullet creation
;3 = bot addon

Type waypoint
Field x,y
Field set
Field current
End Type

Type tracers
Field x,y
Field life
Field lnum
Field timer
Field ox,oy
End Type


Type info
Field txt$
Field timer
End Type

Type client
Field x,y
Field tx,ty
Field angle
Field id
Field status
End Type

Type map
Field x,y
Field terrain
End Type

Type walls
Field x,y
Field width,height
Field sandbag
End Type

Type player
Field x#,y#
Field hp
Field angle
Field timer
Field gun.weapon
Field status,respawn
End Type
Type particle
Field halflife
Field life
Field c
Field xdir
Field ydir
Field x,y
End Type

Type weapon
Field caliber
Field speed
Field clipsize
Field reloadtime
Field rpm
End Type

Type bullet
Field x,y
Field caliber
Field speed
Field angle
Field time
Field friendly
Field dist
End Type

Type spawnpoint
Field x,y
Field team
End Type

AutoMidHandle True

Global playerimage = CreateImage(32,32,1)
Color 0,255,0
SetBuffer(ImageBuffer(playerimage))
Oval 0,0,30,30,1


Include "Angles.bb"
Include "C:\Documents and Settings\Matthew\Desktop\BPP\BPproV2.2.bb"
Include "circles.bb"
Global tileset = LoadAnimImage("tileset\tiles.bmp",tilewidth,tileheight,0,35)

Const tilewidth = 32
Const tileheight = 32
Global worldx
Global worldy
Global mapwidth
Global mapheight
Global host
Global timer = MilliSecs()
Global networktimer = MilliSecs()
Global message$
Global user
Global gametimer = CreateTimer(60)
Global offsetx = MouseX()
Global offsety = MouseY()
Global cMouseX = MouseX()
Global cMouseY = MouseY()
Global music = PlayMusic("music\OFortuna.mp3")
Global word$ = ""
BP_ClearSession()
hostjoin()
SeedRnd BP_GetHostIP()
initializer()

FlushKeys()
HidePointer

;************************************************main loop***********************************
SetBuffer BackBuffer()
While Not KeyHit(1)
Delay(3)
showmap()
updateplayer()
updatebullets()
updateparticles()
updatehud()
Update_Circles()
chat()
If MilliSecs() >= networktimer + 100
BP_UpdateNetwork()
EndIf
readmessages()
updatebots()
updateinfo()
showtracers()
WaitTimer(gametimer)
Flip
Cls
Wend
;*********************************************end of main loop*****************************
BP_Message(0,BP_GetMyID(),10,"")
BP_ClearSession()
End

Function chat()
If KeyHit(28)
i.info = New info
Replace(word," ","~")
BP_Message(0,BP_GetMyID(),7,BP_GetMyName()+": "+word)
word = Replace(word,"~"," ")
i\txt = word
i\timer = MilliSecs()
word = ""
EndIf
w = GetKey()
If w >= 92 And w <= 127
word = word + Chr(w)
EndIf
End Function


Function updatehud()
For person.player = Each player
Color 128,128,128
Rect 75,525,120,40,1
Color 255,0,0
Rect 85,535,person\hp,20,1
Color 0,0,0

If person\status = False
i.info = New info
i\txt = "Respawning"
i\timer = MilliSecs()
Insert i Before First info
EndIf
Next
End Function

Function createwalls()
For tile.map = Each map
Select tile\terrain
Case 0,1,2,3,5,6,7,8,10,11,12,13,15,16,17,18,20,21,22,23
wall.walls = New walls
wall\x = tile\x - tilewidth/2
wall\y = tile\y - tileheight/2
wall\width = tilewidth
wall\height = tileheight
wall\sandbag = False
End Select
If tile\terrain = 3
wall\sandbag = True
EndIf
Next

End Function

Function showmap()
For tile.map = Each map
screenx = getscreenx(tile\x)
screeny = getscreeny(tile\y)
DrawImage tileset,screenx,screeny,tile\terrain
Next
End Function

Function updateplayer()
For person.player = Each player

If person\status = True
worldx = person\x - 400
worldy = person\y - 300
screenx = getscreenx(person\x)
screeny = getscreeny(person\y)

Color 0,255,0
DrawImage playerimage,screenx,screeny

Color 255,0,0
Line screenx,screeny,screenx+ (anglex(person\angle)*.3),screeny - (angley(person\angle)*.3)
oldx = person\x
oldy = person\y
cMouseX = MouseX()
cMouseY = MouseY()
If KeyDown(200)
person\x = person\x + (anglex(person\angle)*.03)
person\y = person\y - (angley(person\angle)*.03)
EndIf
If KeyDown(208)
person\x = person\x -(anglex(person\angle)*.03)
person\y = person\y +(angley(person\angle)*.03)
EndIf

If KeyDown(203)
person\x = person\x -(anglex(predictangle(person\angle,90))*.03)
person\y = person\y +(angley(predictangle(person\angle,90))*.03)
EndIf
If KeyDown(205)
person\x = person\x +(anglex(predictangle(person\angle,90))*.03)
person\y = person\y -(angley(predictangle(person\angle,90))*.03)
EndIf

person\angle = -(ATan2(cMouseX-400,cMouseY-300)+180)
Rect MouseX(),MouseY(),4,4,1
If person\angle < 0
person\angle = 360 + person\angle
ElseIf person\angle > 360
person\angle = person\angle - 360
EndIf
If MilliSecs() >= timer + 100
mantest()
botpacket$ = BP_IntToStr(person\x,4)+BP_IntToStr(person\y,4)+BP_IntToStr(person\angle,2)
botpacket2$ = BP_IntToStr(BP_GetMyID(),2)
botpacket = botpacket + botpacket2
BP_Message(0,BP_GetMyID(),4,botpacket)

person\timer = MilliSecs()
EndIf

person\gun\rpm = person\gun\rpm + 1
If person\gun\rpm > person\gun\speed
If MouseHit(1)
b.bullet = New bullet
b\x = person\x + (anglex(person\angle)*.245)
b\y = person\y - (angley(person\angle)*.245)
b\caliber = person\gun\caliber
b\speed = person\gun\speed
b\angle = person\angle
b\time = MilliSecs()
b\friendly = BP_GetMyID()
b\dist = 0
person\gun\rpm = 0
packet$ = BP_IntToStr(b\x,4) + BP_IntToStr(b\y,4)+BP_IntToStr(b\caliber,2) + BP_IntToStr(b\speed,2)
packet2$ = BP_IntToStr(b\angle,2)
packet = packet+ packet2

;If host = True Then
BP_Message(0,BP_GetMyID(),2,packet)
;ElseIf host = False Then
; BP_Message(BP_GetHostID(),BP_GetMyID(),2,packet)
;EndIf
EndIf
EndIf

For wall.walls = Each walls
If ImageRectCollide(playerimage,person\x,person\y,0,wall\x,wall\y,wall\width,wall\height)
person\x = oldx
person\y = oldy
EndIf

Next
For b.bullet = Each bullet
If ImageRectCollide(playerimage,person\x,person\y,0,b\x,b\y,1,1) And (b\friendly <> BP_GetMyID())
person\hp = person\hp - (b\caliber*1.5)
launchparticles(b\x,b\y,5)
Delete b
EndIf
If person\hp <= 0
packet$ = BP_IntToStr(BP_GetMyID(),2)
BP_Message(0,BP_GetMyID(),5,packet)
person\status = False
person\respawn = MilliSecs()
goCircle.tCircle = Create_Circle(person\x,person\y,15)

Break_Circle(goCircle)
Exit
EndIf
Next
ElseIf MilliSecs() >= person\respawn+5000
person\status = True
person\hp = 100
BP_Message(0,BP_GetMyID(),6,"")
count = 0
For spawn.spawnpoint = Each spawnpoint
count = count + 1
Next
count = Rand(1,count)
spawn.spawnpoint = First spawnpoint
For i = 1 To count
If i = count Then
rx = spawn\x
ry = spawn\y
EndIf
spawn.spawnpoint = After spawn
Next

person\x = rx
person\y = ry

EndIf
Next
End Function


Function getdist(x,y,tx,ty)
dx = x - tx
dy = y - ty
dist = Sqr((dx*dx)+(dy*dy))
Return dist
End Function

Function updatebots()
For bot.client = Each client
If bot\status
Color 255,0,0
tempangle = ATan2(bot\tx-bot\x,-(bot\ty-bot\y))
screenx = bot\x - worldx
screeny = bot\y - worldy
If tempangle < 0
tempangle = 360 + tempangle
ElseIf tempangle > 360
tempangle = tempangle - 360
EndIf
dist = Sqr(((bot\x - bot\tx)^2) + ((bot\y - bot\ty)^2))
If dist < 5

move = getnextwaypoint(bot\id)

bot\tx = getwayx(bot\id)
bot\ty = getwayy(bot\id)

EndIf
If dist >= 5
bot\x = bot\x +(anglex(tempangle)*.06)
bot\y = bot\y -(angley(tempangle)*.06)
EndIf

DrawImage playerimage,screenx,screeny
Line bot\x-worldx,bot\y-worldy,bot\x+(anglex(bot\angle)/5)-worldx,bot\y - (angley(bot\angle)/5)-worldy
For b.bullet = Each bullet
If ImageRectCollide(playerimage,bot\x,bot\y,0,b\x,b\y,1,1) And b\friendly <> bot\id
Delete b
EndIf
Next
EndIf
Next
End Function

Function updatebullets()
For b.bullet = Each bullet
Color 200,200,200
ox = b\x
oy = b\y
b\x = b\x + (anglex(b\angle)*.3)
b\y = b\y - (angley(b\angle)*.3)
createtracers(b\x,b\y,ox,oy)
screenx = getscreenx(b\x)
screeny = getscreeny(b\y)
If b\time+10000 <= MilliSecs()
Delete b
Exit
EndIf
If b\time+1000 <= MilliSecs()
b\dist = True
EndIf
;Rect screenx,screeny,2,2,0
For wall.walls = Each walls
If RectsOverlap(b\x,b\y,2,2,wall\x,wall\y,wall\width,wall\height)
If wall\sandbag = True And b\dist <> True

If Rand(1,3) = 3
launchparticles(b\x,b\y,10)
Delete b
Exit
EndIf
ElseIf b\dist <> True
launchparticles(b\x,b\y,10)
Delete b
Exit
EndIf
EndIf
Next

Next
End Function

Function createtracers(x,y,ox,oy)
path.tracers = New tracers
path\x = x
path\y = y
path\ox = ox
path\oy = oy
path\life = 30
path\lnum = 10
path\timer = MilliSecs()
End Function

Function showtracers()
For path.tracers = Each tracers
Color 5*path\life,5*path\life,0
screenx = getscreenx(path\x)
screeny = getscreeny(path\y)
oscreenx = getscreenx(path\ox)
oscreeny = getscreeny(path\oy)
Line screenx,screeny,oscreenx,oscreeny
If MilliSecs() >= path\timer + path\life
path\life = path\life - path\lnum
path\timer = MilliSecs()
If path\life < 0 Then Delete path
EndIf
Next
End Function

Function findangle(x,y,tx,ty)

angle = -1
champ = MilliSecs()
For rotations = 0 To 360
dx = x + anglex(rotations)*.03
dy = y - angley(rotations)*.03
challenger = finddist(dx,dy,tx,ty)
If challenger < champ Then
champ = challenger
angle = rotations
EndIf
Next
Return angle
End Function
Function launchparticles(x,y,num)
For i = 1 To num
p.particle = New particle
p\x = x
p\y = y
p\xdir = Rand(-1,1)
p\ydir = Rand(1,2)
p\halflife = Rand(1,3)
p\life = MilliSecs()
p\c = $ff8888
Next
End Function

Function updateparticles()
For p.particle = Each particle
For i = 1 To 2
For e = 1 To 2
WritePixel p\x+i-worldx,p\y+e-worldy,p\c
Next
Next
p\c = p\c - 8
p\x = p\x + p\xdir
p\y = p\y + p\ydir
If MilliSecs() >= (p\life+p\halflife*200) Then
Delete p
EndIf
Next
End Function


Function initializer()
loadmap()
createwalls()
createplayer()
End Function

Function createplayer()
person.player = New player
count = 0
For spawn.spawnpoint = Each spawnpoint
count = count + 1
Next
count = Rand(1,count)
spawn.spawnpoint = First spawnpoint
For i = 1 To count
If i = count Then
rx = spawn\x
ry = spawn\y
EndIf
spawn.spawnpoint = After spawn
Next

person\x = rx
person\y = ry
person\hp = 100
person\angle = 0
person\timer = MilliSecs()
person\gun.weapon = New weapon
person\gun\caliber = 30
person\gun\speed = 20
person\gun\reloadtime = 7000
person\gun\rpm = 500
person\status = True
person\respawn = 5000
If host = False
packet$ = BP_IntToStr(person\x,4) + BP_IntToStr(person\y,4) + BP_IntToStr(person\angle,2)
packet2$ = BP_IntToStr(BP_GetMyID())
packet = packet + packet2
BP_Message(BP_GetHostID(),BP_GetMyID(),3,packet)
EndIf

End Function

Function getscreenx(x)
screenx = x - worldx
Return screenx
End Function

Function getscreeny(y)
screeny = y - worldy
Return screeny
End Function


Function loadmap()

filein = OpenFile("newmap.dat")
mapwidth = ReadInt(filein)
mapheight = ReadInt(filein)
For tile.map = Each map
Delete tile
Next
For x = 1 To (mapwidth*tilewidth) Step tilewidth
For y = 1 To (mapheight*tileheight) Step tilewidth
tile.map = New map
tile\x = ReadInt(filein)
tile\y = ReadInt(filein)
tile\terrain = ReadInt(filein)
Next
Next
spawns = ReadInt(filein)
For i = 0 To spawns - 1
spawn.spawnpoint = New spawnpoint
spawn\x = ReadInt(filein)
spawn\y = ReadInt(filein)
spawn\team = ReadInt(filein)
Next
End Function

Function savemap()
fileout = WriteFile("newmap.dat")
WriteInt(fileout,mapwidth)
WriteInt(fileout,mapheight)
For tile.map = Each map
WriteInt(fileout,tile\x)
WriteInt(fileout,tile\y)
WriteInt(fileout,tile\terrain)
Next
spawnnum = 0
For spawn.spawnpoint = Each spawnpoint
spawnnum = spawnnum + 1
Next
WriteInt(fileout,spawnnum)
For spawn.spawnpoint = Each spawnpoint
WriteInt(fileout,spawn\x)
WriteInt(fileout,spawn\y)
WriteInt(fileout,spawn\team)
Next
End Function


Function updateinfo()
counter = 0
For i.info = Each info
Text 0,counter*12,i\txt
counter = counter + 1
If counter > 5 Or MilliSecs() >= i\timer + 5000
Delete i
Exit
EndIf
Next
End Function

Function finddist(tx,ty,x,y)

xdist = tx - x
ydist = ty - y
TotalDist = Sqr#((xdist * xdist) + (ydist * ydist))
Return TotalDist

End Function

Function predictangle(angle,offset)
angle = angle + offset
If angle < 0 Then
angle = 360 - angle
EndIf
If angle > 360 Then
angle = angle - 360
EndIf
Return angle
End Function

;***********************************************NETWORK CODE******************************************
Function hostjoin()
Repeat
SetBuffer FrontBuffer()
Text 0,10,"Would you like to [H]ost or [J]oin? "
Locate 0,22
If KeyHit(35)
FlushKeys()
hostname$ = Input("What is your username? ")
gamename$ = Input("What is your game's name? ")
If BP_HostSession(gamename,2223)

host = True
Locate 0,34
i.info = New info
i\txt = "successfully started server"
i\timer = MilliSecs()
Insert i Before First info
player = BP_CreatePlayer(hostname)
Text 0,30,"Server started"

WaitKey()
Exit
EndIf
Text 0,30,"server failed"
WaitKey()
End
ElseIf KeyHit(36)
FlushKeys()
username$ = Input("What is your username? ")
Locate 0,20
gameip$ = Input("What is the servers ip adress?")
If gameip = "" Then gameip = "127.0.0.1"

Success = BP_JoinSession(gameip,2223,2232,"",10)
player% = BP_CreatePlayer(username)
Select Success
Case BP_NOREPLY
Print "No reply from host"
WaitKey()
End
Case BP_PORTNOTAVALIABLE
Print "Port not avaliable"
WaitKey()
End
Case BP_SUCCESS
Print "Game joined"
Case BP_IAMBANNED
Print "I am banned:<"
WaitKey()
End
Case BP_GAMEISFULL
WaitKey()
End
Print "Game is full"
Case BP_USERABORT
Print "Game aborted"
WaitKey()
End
Case BP_INVALIDHOSTIP
Print "Bad IP adress"
End Select



host = False
Exit
EndIf

Forever

End Function

Function readmessages()
For msg.BP_MsgInfo = Each BP_MsgInfo
Select msg\msgType
Case 255
;new player event
i.info = New info
i\txt = BP_GetPlayerName(msg\msgFrom) + "has joined the game"
i\timer = MilliSecs()
Insert i Before First info
If host = True Then
person.player = First player
packet$ = BP_IntToStr(person\x,4) + BP_IntToStr(person\y,4) + BP_IntToStr(person\angle)
packet2$ = BP_IntToStr(BP_GetMyID(),2)
packet = packet + packet2
BP_Message(msg\msgFrom,BP_GetMyID(),3,packet)
For bot.client = Each client
If bot\id <> msg\msgFrom
packet$ = BP_IntToStr(bot\x,4) + BP_IntToStr(bot\y,4) + BP_IntToStr(bot\angle,2)
BP_Message(msg\msgFrom,BP_GetMyID(),3,packet)
EndIf
Next
EndIf
Case 1
;chat message
i.info = New info
from$ = BP_GetPlayerName(BP_StrToInt(Mid(msg\msgData,1,2)))
stringsize = BP_StrToInt(Mid(msg\msgData,3,2))
i\txt = "["+from+"]"+BP_StrToInt(Mid(msg\msgData,5,stringsize))
i\timer = MilliSecs()
Insert i Before First info
Case 2
;new bullet data
b.bullet = New bullet
b\x = BP_StrToInt(Mid(msg\msgData,1,4))
b\y = BP_StrToInt(Mid(msg\msgData,5,4))
b\time = MilliSecs()
b\caliber = BP_StrToInt(Mid(msg\msgData,9,2))
b\speed = BP_StrToInt(Mid(msg\msgData,11,2))
b\angle = BP_StrToInt(Mid(msg\msgData,13,2))
b\dist = 0
b\friendly = msg\msgFrom
Case 3
If msg\msgFrom <> BP_GetMyID()
;new bot data
bot.client = New client
bot\x = BP_StrToInt(Mid(msg\msgData,1,4))
bot\y = BP_StrToInt(Mid(msg\msgData,5,4))
bot\angle = BP_StrToInt(Mid(msg\msgData,9,2))
bot\id = msg\msgFrom
bot\status = True
addwaypoint(bot\x,bot\y,bot\id,True)
EndIf
Case 4
;bot update data
If msg\msgFrom <> BP_GetMyID() Then
For bot.client = Each client
If bot\id = msg\msgFrom Then

x = BP_StrToInt(Mid(msg\msgData,1,4))
y = BP_StrToInt(Mid(msg\msgData,5,4))
bot\tx = x
bot\ty = y
bot\angle = BP_StrToInt(Mid(msg\msgData,9,2))
Exit
EndIf
Next
EndIf
Case 5
;player killed
For bot.client = Each client
If bot\id = msg\msgFrom Then
goCircle.tCircle = Create_Circle(bot\x,bot\y,15)
Break_Circle(goCircle)
bot\status = False
Exit
EndIf
Next
Case 6
;player respawn
For bot.client = Each client
If bot\id = msg\msgFrom Then
bot\status = True
Exit
EndIf
Next
Case 7
;player chat message, simply chat....
i.info = New info
i\txt = Replace(msg\msgData,"~"," ")
i\timer = MilliSecs()
Case 10
;player has left the game
For bot.client = Each client
If bot\id = msg\msgFrom Then
Delete bot
EndIf
Next
End Select
Delete msg
Next
End Function
;**********************************************END NETWORK CODE***************************************
Function addwaypoint(x,y,set,change)
w.waypoint = New waypoint
w\set = set
w\x = x
w\y = y
If change = False
w\current = False
Else
w\current = True
EndIf
End Function

Function getnextwaypoint(set)
pastset = False
For w.waypoint = Each waypoint
If w\set = set And w\current = True
tempx = w\x
tempy = w\y
Delete w
pastset = True
Else
If w\set = set And pastset = True And w\current = False
w\current = True
Exit
EndIf
EndIf
Next
If pastset = True
w.waypoint = New waypoint
w\x = tempx
w\y = tempy
w\set = set
w\current = True
EndIf
Return 1
End Function

Function getwayx(set)
For w.waypoint = Each waypoint
If w\current = True And w\set = set
Return w\x
EndIf
Next
End Function

Function getwayy(set)
For w.waypoint = Each waypoint
If w\current = True And w\set = set
Return w\y
EndIf
Next
End Function


Function addbot()
person.player = First player
bot.client = New client
bot\x = person\x
bot\y = person\y
bot\tx = person\x
bot\ty = person\y
bot\angle = person\angle
bot\id = BP_GetMyID()
bot\status = True
w.waypoint = New waypoint
w\x = person\x
w\y = person\y
w\current = True
w\set = BP_GetMyID()
End Function
Function mantest()
person.player = First player
w.waypoint = New waypoint
w\x = person\x
w\y = person\y
w\current = 0
w\set = BP_GetMyID()
End Function

------------------
"Do not condemn others for their ignorance, use it against them."
Scott E. Roeben

firemaker103

Member

Posts: 643
From:
Registered: 07-13-2005
I will also need the media!

------------------
"Be nice to the nerds because later on, you'll be working for them" - Bill Gates

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
sorry bout that, heres the link :
www.freewebs.com/mlanet/soldat.zip

------------------
"Do not condemn others for their ignorance, use it against them."
Scott E. Roeben