All my efforts are in vain, this code doesn't work... the function call is not pasing the variables as I thought it was going to happen...
Here have a look.
`Project: Phong
`Author: Alexis Solano
`Created: 12/30/2004 9:15:28 PM
`Set Sync
SYNC ON : SYNC RATE 60
`Window Resolution, Size & Full Screen Mode, No Mouse
`Set Resolution
SET DISPLAY MODE 1024,768,0
`Set Size
SET WINDOW SIZE 1024,768
`Set Full Screen Mode
`SET WINDOW OFF
`Turn Off Mouse
`POSITION MOUSE 0,0
`HIDE MOUSE
`Set Chroma - Key
SET IMAGE COLORKEY 50,50,50
`Set-Up Stage, Players and Disk
`Create and place Background
LOAD Image "phong_background_aqua.jpg",1
SPRITE 1,-1024,0,1
SET SPRITE 1,0,0
`Create and place Scrolling Background
SPRITE 2,0,0,1
SET SPRITE 1,0,0
`Create and place borders
`Top Border
LOAD IMAGE "phong_background_border_aqua.png",3
SPRITE 3,10,15,3
SET SPRITE 1,0,1
`Bottom Border
SPRITE 4,10,660,3
SET SPRITE 2,0,1
`Create and place Players
`Player One
LOAD IMAGE "phong_table.png",10
SPRITE 10,100,250,10
SET SPRITE 10,0,1
`Player Two
LOAD IMAGE "phong_table_2.png",11
SPRITE 11,875,250,11
SET SPRITE 11,0,1
`Create and place Ball
LOAD IMAGE "phong_disk.png",12
SPRITE 12,480,325,12
SET SPRITE 12,0,1
`Set Variables for speed
`Player One Sped
PlayerOneSpeedUp# = 20
PlayerOneSpeedDown# = 20
PlayerOneSpeedLeft# = 5
PlayerOneSpeedRight# = 5
`Player Two Speed
`Disk Speed
`Main Loop
DO
`Get Objects Coordenates
GetCoordenates(Player1X#,Player1Y#,Player2X#,Player2Y#,DiskX#,DiskY#,BgX1#,BgY1#,BgX2#,BgY2#,BorderTopX#,BorderTopY#,BorderBottomX#,BorderBottomY#)
`Control Player One Movement
PlayerOneMovement(PlayerOneSpeedUp#,PlayerOneSpeedDown#,PlayerOneSpeedLeft#,PlayerOneSpeedRight#)
`Colision
ColisionDetector()
`Scrolling Background
ScrollingBg()
`Clean the screena and Sync
CLS : SYNC
LOOP
`Functions
FUNCTION PlayerOneMovement(PlayerOneSpeedUp#,PlayerOneSpeedDown#,PlayerOneSpeedLeft#,PlayerOneSpeedRight#)
`Assign the latest value to the player
GetCoordenates(Player1X#,Player1Y#,Player2X#,Player2Y#,DiskX#,DiskY#,BgX1#,BgY1#,BgX2#,BgY2#,BorderTopX#,BorderTopY#,BorderBottomX#,BorderBottomY#)
`Move Up
IF UPKEY() = 1 THEN Player1Y# = SPRITE Y (10) - PlayerOneSpeedUp#
`Move Down
IF DOWNKEY() = 1 THEN Player1Y# = SPRITE Y (10) + PlayerOneSpeedDown#
`Move Left
IF LEFTKEY() = 1 THEN Player1X# = SPRITE X (10) - PlayerOneSpeedLeft#
`Move Right
IF RIGHTKEY() = 1 THEN Player1X# = SPRITE X (10) + PlayerOneSpeedRight#
`Update Sprite Position ( X - Y )
SPRITE 10,Player1X#,Player1Y#,10
ENDFUNCTION
FUNCTION ColisionDetector()
`Get The Player One Coordenates
GetCoordenates(Player1X#,Player1Y#,Player2X#,Player2Y#,DiskX#,DiskY#,BgX1#,BgY1#,BgX2#,BgY2#,BorderTopX#,BorderTopY#,BorderBottomX#,BorderBottomY#)
`Set the colide variables
ColideBorderTop = SPRITE COLLISION(10,3)
ColideBorderBottom = SPRITE COLLISION(10,4)
`Add the logic for detection
`Colide with the Top & Bottom Borders
IF ColideBorderTop = 1 THEN Player1Y# = Player1Y# + 25
IF ColideBorderBottom = 1 THEN Player1Y# = Player1Y# - 25
`Update Sprite
SPRITE 10,Player1X#,Player1Y#,10
ENDFUNCTION
FUNCTION ScrollingBg()
`Set Background Coordenates ( X - Y )
GetCoordenates(Player1X#,Player1Y#,Player2X#,Player2Y#,DiskX#,DiskY#,BgX1#,BgY1#,BgX2#,BgY2#,BorderTopX#,BorderTopY#,BorderBottomX#,BorderBottomY#)
`Loop The Background
IF BgX2# < 1024
BgX2# = SPRITE X (2) + 5
ENDIF
IF BgX2# > 0
BgX1# = SPRITE X (1) + 5
ENDIF
IF BgX1# > 1
BgX2# = 0
BgX1# = -1024
ENDIF
`Update Sprite On Screen
SPRITE 1,BgX1#,BgY1#,1
SPRITE 2,BgX2#,BgY2#,1
ENDFUNCTION
FUNCTION GetCoordenates(Player1X#,Player1Y#,Player2X#,Player2Y#,DiskX#,DiskY#,BgX1#,BgY1#,BgX2#,BgY2#,BorderTopX#,BorderTopY#,BorderBottomX#,BorderBottomY#)
`Get The Player One Coordenates
Player1X# = SPRITE X (10)
Player1Y# = SPRITE Y (10)
`Get The Player Two Coordenates
Player2X# = SPRITE X (11)
Player2Y# = SPRITE Y (11)
`Get Disk Coordenates
DiskX# = SPRITE X (12)
DiskY# = SPRITE Y (12)
`Get Background Coordenates
`Get Plane 1
BgX1# = SPRITE X (1)
BgY1# = SPRITE y (1)
`Get Plane 2
BgX2# = SPRITE X (2)
BgY2# = SPRITE y (2)
`Get the Top Border
BorderTopX# = SPRITE X (3)
BorderTopY# = SPRITE Y (3)
`Get the Bottom Border
BorderBottomX# = SPRITE X (4)
BorderBottomY# = SPRITE Y (4)
ENDFUNCTION
- Just Me!