Was denn?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu// --------------------------------- //
// Project: cannon
// Start: Wednesday, March 17, 2010
// IDE Version: 7.082
TYPE Tcannon
x
y
power
phi
isAlive
shoot
ENDTYPE
TYPE Tbowl
x
y
dir_x
dir_y
ENDTYPE
SETCURRENTDIR("Media") // seperate media and binaries?
//GFX
LOADSPRITE "cannon.png", 0 //cannon-foot
LOADSPRITE "cannon1.png", 1 //cannon
LOADSPRITE "bowl.png", 2 //cannon bowl
//GLOBALS
GLOBAL scr_x, scr_y
GETSCREENSIZE scr_x, scr_y //get the screensize into scr_x and scr_y
GLOBAL cannon AS Tcannon //Create a newcannonn
GLOBAL newBowl AS Tbowl
GLOBAL bowls[] AS Tbowl
//Set the cannon properties
cannon.x = scr_x/2-64
cannon.y = scr_y-38
cannon.power = 1
cannon.phi = 0
cannon.isAlive = TRUE
//CONSTANTS
GLOBAL LEFT% = 203
GLOBAL RIGHT% = 205
GLOBAL SPACE% = 57
WHILE TRUE //main loop
DRAWRECT 0,0,scr_x,scr_y,RGB(200,200,255)
//For each shot do this
FOREACH Shot IN bowls[]
INC Shot.x, Shot.dir_x
INC Shot.y, Shot.dir_y
DRAWSPRITE 2,Shot.x,Shot.y //Draw the cannon ball
NEXT
IF cannon.isAlive = TRUE
IF KEY(LEFT%) //turn left
IF cannon.phi<180
INC cannon.phi, 2
ENDIF
ENDIF
IF KEY(RIGHT%) //turn right
IF cannon.phi>0
DEC cannon.phi, 2
ENDIF
ENDIF
IF KEY(SPACE%) //shoot
IF cannon.shoot
//create a new shot
newBowl.x = cannon.x + 80
newBowl.y = cannon.y + 16
newBowl.dir_x = SIN(cannon.phi) //??????????????????????????
newBowl.dir_y = COS(cannon.phi) //??????????????????????????
DIMPUSH bowls[], newBowl
cannon.shoot = FALSE //only one shot per press
ENDIF
ELSE
cannon.shoot = TRUE //if space = unpressed then shoot = true
ENDIF
ROTOSPRITE 1, cannon.x, cannon.y, cannon.phi //Draw the cannon
DRAWSPRITE 0,scr_x/2-16,scr_y-32 //Draw the cannon-foot
ENDIF
SHOWSCREEN //Draw the screen
WEND //aaaaaand again