Posted: Fri Jun 11, 2004 8:41 pm
You do realize that resolution is probably impossible in Blitz, right? I don't think you know what you're talking about....640 x 640 screen
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
You do realize that resolution is probably impossible in Blitz, right? I don't think you know what you're talking about....640 x 640 screen
Code: Select all
Type "Name Of Type"
Field "All Variables That Make Up This Type"
End Type
Code: Select all
Type Bullet
Field Bulletx,Bullety,BulletxVelocity,BulletyVelocity
End Type
Code: Select all
Global SpecialBullet.Bullet = New Bullet
Code: Select all
SpecialBullet\Bulletx = 20
SpecialBullet\Bullety = 15
SpecialBullet\BulletxVelocity = 5 ;and so on...
Code: Select all
Function SayHi()
Text 0,0,"Hello?"
End Function
Code: Select all
Function SayHi(xPosition,yPosition)
Text xPosition,yPosition,"Hello?"
End Function
Code: Select all
SayHi(25,74)
Code: Select all
;Bullet Demo by JS Lemming
;Set graphics mode
Graphics 640,480
;Set buffer to backbuffer
SetBuffer BackBuffer()
;Declare our Bullet Type (only has 2 variables)
Type Bullet
Field Bulletx,Bullety
End Type
;Create a variable to hold the player's y position
Global PlayerY = 200
;While the user doesn't press the ESC key...
While Not KeyDown(1)
;Clear the screen
Cls
;Goto function for key input
UserInput()
;This one moves the bullets
UpdateBullets()
;Now, it is time to draw the bullets
DrawBullets()
;Draw the player as a green oval
Color 0,255,0
Oval 5,PlayerY,50,50,1
;Flip screen into view
Flip
Wend
;This function will create a bullet type when called
Function CreateBullet()
;Create the type
Bullet.Bullet = New Bullet
;Set Bulletx to 20
Bullet\Bulletx = 20
;Set Bullety to equal player's current y position
Bullet\Bullety = PlayerY + 20
;I added 25 to PlayerY so the bullet is centered with green boy
End Function
;This function updates the bullets' position
Function UpdateBullets()
;For this, we must LOOP through every bullet that we
; have created so far
For Current.Bullet = Each Bullet
;Add 8 to each bullet's x
Current\Bulletx = Current\Bulletx + 8
Next
End Function
;This function loops through each bullet and draws them in there
; correct position
Function DrawBullets()
For Current.Bullet = Each Bullet
;Turn color to red
Color 255,0,0
;Draw a rectangle to represent the bullet
Rect Current\Bulletx,Current\Bullety,20,10,1
Next
End Function
;This function deals with key input from the user
Function UserInput()
;See if user is pressing up or down keys, and more player accordingly
If KeyDown(200) Then PlayerY = PlayerY - 3
If KeyDown(208) Then PlayerY = PlayerY + 3
;See if user pressed the space bar, if so, create a bullet
If KeyHit(57) Then CreateBullet()
;Cange this to KeyDown(57) for rapid fire!
End Function
Code: Select all
Function SaveGame()
Print "Auto Saving....."
fileout = WriteFile("gameinfo.tcr")
WriteString( fileout, name$ )
WriteString( fileout, gender$ )
WriteString( fileout, age )
WriteString( fileout, strength )
WriteString( fileout, speed )
WriteString( fileout, defence )
WriteString( fileout, health )
WriteString( fileout, status$ )
CloseFile( fileout )
For i = 0 to 6
Write "."
Delay 500
Next
Print "Save Complete."
Delay 5000
End Function
I remembered that before I emptied my trash can with my first graphical program in it. Maybe I can learn from this piece of sh*t.....We can all learn from our mistakes! - First grade teacher
I doubt you'd think I'd have THIS many problems, but here's my code:Hope that answers some of your questions. Post if you run into problems.
Code: Select all
; Marcel's attempted two player shooter
; enables graphics mode
Graphics 640,480
; sets charactor's life
Global Playeronelife=3
Global Playertwolife=3
; repeat the below
Repeat
; if your hit by a bullet, take a life
If playeroneBullety=playeroneY Then
playeronelife-1
EndIf
If playertwoBullety=playertwoY Then
playertwolife-1
EndIf
;if you don't have any more lives, you loose, and program ends
If playeronelife=0 Then
Cls
Print 320,240 "Red, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Print 320,240 "GAME OVER"
Print 320,245 "Blue wins!
Delay 10000
End
EndIf
If playertwolife=0 Then
Cls
Print 320,240 "Blue, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Print 320,240 "GAME OVER"
Print 320,245 "RED wins!
Delay 10000
End
EndIf
; repeats the above forever
Forever
; allows you to walk off the top of the screen and appear on the bottom
If playeroneY > 640
playeroneY = 0
ElseIf playeroneY < 0
playeroneY = 640
EndIf
If playertwoY > 640
playertwoY = 0
ElseIf playertwoY < 0
playertwoY = 640
EndIf
; generates a buffer
SetBuffer BackBuffer()
; types
Type playeroneBullet
Field playeroneBulletx,playeroneBullety
End Type
Type playertwoBullet
Field playertwoBulletx,playertwoBullety
End Type
Type playerone
Field x,y
End Type
Type playertwo
Field x,y
End Type
; sets your Y coordinations
PlayeroneY = 200
PlayertwoY = 200
; while esc isn't being held
While Not KeyDown(1)
; clear the screen
Cls
; loads all required images
Global playerone = LoadImage("playerone.bmp")
Global playertwo = LoadImage("playertwo.bmp")
Global bulletone = LoadImage("playeronebullet.bmp")
Global bullettwo = LoadImage("playertwobullet.bmp")
; does these functions
UseroneInput()
UpdateplayeroneBullets()
DrawplayeroneBullets()
UsertwoInput()
UpdateplayertwoBullets()
DrawplayertwoBullets()
; draws playerone and two
DrawImage(playerone, playeroneY, 5)
DrawImage(playertwo, playertwoY, 475)
; flip screen into view
Flip
Wend
; _________________________Player ONE Functions_________________
Function CreateBulletone()
playeroneBullet.playeroneBullet = New playeroneBullet
playeroneBullet\playeroneBulletx = 20
playeroneBullet\playeroneBullety = PlayeroneY + 10
End Function
Function UpdatePlayeroneBullets()
For Current.Bulletone = Each Bulletone
Current\Bulletonex = Current\Bulletonex + 8
Next
End Function
Function DrawPLayeroneBullets()
For Current.playeroneBullet = Each playeroneBullet
DrawImage(playeronebullet, playeroneBullet\playeroneBullety,playeroneBullet\playeroneBulletx)
End Function
Function UseroneInput()
If KeyDown(200) Then PlayeroneY = PlayeroneY - 3
If KeyDown(208) Then PlayeroneY = PlayeroneY + 3
If KeyHit(203) Then CreateplayeroneBullet()
End Function
; __________________Player TWO Functions_______________________
Function CreateBulletone()
playertwoBullet.playertwoBullet = New playertwoBullet
playertwoBullet\playertwoBulletx = 460
playertwoBullet\playertwoBullety = PlayertwoY - 10
End Function
Function UpdatePlayertwoBullets()
For Current.playertwoBullet = Each playertwoBullet
Current\playertwoBulletx = Current\playertwoBulletx - 8
Next
End Function
Function DrawPLayertwoBullets()
For Current.playertwoBullet = Each playertwoBullet
DrawImage(playertwobullet, playertwoBullet\playertwoBullety,playertwoBullet\playertwoBulletx)
End Function
Function UsertwoInput()
If KeyDown(30) Then PlayertwoY = PlayertwoY - 3
If KeyDown(31) Then PlayertwoY = PlayertwoY + 3
If KeyHit(57) Then CreateplayertwoBullet()
End Function
Code: Select all
Print 320,240 "Red, YOU SUCK!You LOOSE!"
Code: Select all
Text 320,240,"Red, YOU SUCK!You LOOSE!"
Code: Select all
; while esc isn't being held
While Not KeyDown(1)
; clear the screen
Cls
; loads all required images
Global playerone = LoadImage("playerone.bmp")
Global playertwo = LoadImage("playertwo.bmp")
Global bulletone = LoadImage("playeronebullet.bmp")
Global bullettwo = LoadImage("playertwobullet.bmp")
; does these functions
UseroneInput()
UpdateplayeroneBullets()
DrawplayeroneBullets()
UsertwoInput()
UpdateplayertwoBullets()
DrawplayertwoBullets()
; draws playerone and two
DrawImage(playerone, playeroneY, 5)
DrawImage(playertwo, playertwoY, 475)
; flip screen into view
Flip
Wend
Code: Select all
If PlayerX > 40 and PlayerX + 15 < 40
PlayerX = PlayerX * 2
If Score < 50
text 0,0,"You Stink"
endif
for i=0 to 75
PlayerY = PlayerY + 6
if PlayerY < i
text 0,0,"You loose!"
endif
next
endif
Code: Select all
If PlayerX > 40 And PlayerX + 15 < 40
PlayerX = PlayerX * 2
If Score < 50
Text 0,0,"You Stink"
EndIf
For i=0 To 75
PlayerY = PlayerY + 6
If PlayerY < i
Text 0,0,"You loose!"
EndIf
Next
EndIf
Code: Select all
; enables graphics mode
Graphics 640,480
; sets charactor's life
Global Playeronelife=3
Global Playertwolife=3
; repeat the below
Repeat
; if your hit by a bullet, take a life
If playeroneBullety=playeroneY Then
Playeronelife=Playeronelife-1
EndIf
If playertwoBullety=playertwoY Then
Playertwolife=Playertwolife-1
EndIf
;if you don't have any more lives, you loose, and program ends
If playeronelife=0 Then
Cls
Text 320,240, "Red, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Text 320,240, "GAME OVER"
Text 320,245, "Blue wins!
Delay 10000
End
EndIf
If playertwolife=0 Then
Cls
Text 320,240, "Blue, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Text 320,240, "GAME OVER"
Text 320,245, "RED wins!
Delay 10000
End
EndIf
; repeats the above forever
Forever
; allows you to walk off the top of the screen and appear on the bottom
If playeroneY > 640
playeroneY = 0
ElseIf playeroneY < 0
playeroneY = 640
EndIf
If playertwoY > 640
playertwoY = 0
ElseIf playertwoY < 0
playertwoY = 640
EndIf
; generates a buffer
SetBuffer BackBuffer()
; types
Type playeroneBullet
Field playeroneBulletx,playeroneBullety
End Type
Type playertwoBullet
Field playertwoBulletx,playertwoBullety
End Type
Type playerone
Field x,y
End Type
Type playertwo
Field x,y
End Type
; sets your Y coordinations
PlayeroneY = 200
PlayertwoY = 200
; loads all required images
Global playerone = LoadImage("playerone.bmp")
Global playertwo = LoadImage("playertwo.bmp")
Global bulletone = LoadImage("playeronebullet.bmp")
Global bullettwo = LoadImage("playertwobullet.bmp")
; while esc isn't being held
While Not KeyDown(1)
; clear the screen
Cls
; does these functions
UseroneInput()
UpdateplayeroneBullets()
DrawplayeroneBullets()
UsertwoInput()
UpdateplayertwoBullets()
DrawplayertwoBullets()
; draws playerone and two
DrawImage(playerone, playeroneY, 5)
DrawImage(playertwo, playertwoY, 475)
; flip screen into view
Flip
Wend
; _________________________Player ONE Functions_________________
Function CreateplayeroneBullet()
playeroneBullet.playeroneBullet = New playeroneBullet
playeroneBullet\playeroneBulletx = 20
playeroneBullet\playeroneBullety = PlayeroneY + 10
End Function
Function UpdatePlayeroneBullets()
For Current.playeroneBullet = Each playeroneBullet
Current\playeroneBulletx = Current\playeroneBulletx + 8
Next
End Function
Function DrawPlayeroneBullets()
For Current.playeroneBullet = Each playeroneBullet
DrawImage(bulletone, playeroneBullety,playeroneBulletx)
Next
End Function
Function UseroneInput()
If KeyDown(200) Then PlayeroneY = PlayeroneY - 3
If KeyDown(208) Then PlayeroneY = PlayeroneY + 3
If KeyHit(203) Then CreateplayeroneBullet()
End Function
; __________________Player TWO Functions_______________________
Function CreateBullettwo()
playertwoBullet.playertwoBullet = New playertwoBullet
playertwoBullet\playertwoBulletx = 460
playertwoBullet\playertwoBullety = PlayertwoY - 10
End Function
Function UpdatePlayertwoBullets()
For Current.playertwoBullet = Each playertwoBullet
Current\playertwoBulletx = Current\playertwoBulletx - 8
Next
End Function
Function DrawPLayertwoBullets()
For Current.playertwoBullet = Each playertwoBullet
DrawImage(playertwobullet, playertwoBullety,playertwoBulletx)
Next
End Function
Function UsertwoInput()
If KeyDown(30) Then PlayertwoY = PlayertwoY - 3
If KeyDown(31) Then PlayertwoY = PlayertwoY + 3
If KeyHit(57) Then CreateBullettwo()
End Function
Code: Select all
; repeat the below
Repeat
; if your hit by a bullet, take a life
If playeroneBullety=playeroneY Then
Playeronelife=Playeronelife-1
EndIf
If playertwoBullety=playertwoY Then
Playertwolife=Playertwolife-1
EndIf
;if you don't have any more lives, you loose, and program ends
If playeronelife=0 Then
Cls
Text 320,240, "Red, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Text 320,240, "GAME OVER"
Text 320,245, "Blue wins!
Delay 10000
End
EndIf
If playertwolife=0 Then
Cls
Text 320,240, "Blue, YOU SUCK!You LOOSE!"
Delay 5000
Cls
Text 320,240, "GAME OVER"
Text 320,245, "RED wins!
Delay 10000
End
EndIf
; repeats the above forever
Forever