Here's a couple of suggestions in hopes that this project won't die.
1. Decide on a structure for the program. I saw a skeleton earlier on, but I don't see any real adherence to it.
2. Organize the code a little more consistently
It seems there are tons of little snippets here and there, but no standard or complete structure of the code. There are multiple screen resolutions, main loops, variables used here and there... This needs to be gelled a little more - just for ease of adding to it or removing and editing things.
3. Don't be afraid to take on a task that isn't getting done. If someone has disappeared and you really want to finish this thing, pick up their slack and work out that portion of the program.
4. The only way this'll get done is if it gets worked on.
For number 2, I went through most of the messages in this thread and gleaned what I thought were the most complete blocks of code. I organized them in a coding structure I use often and included it as a code snippet.
The top part is the header. It has the project title, the date etc. It also has a comment section. This is useful to maintain a change log of additions or changes to the program. If you date each entry (the most recent at the top) you can get an idea of progress.
The next section is the main loop. This is where the main subroutines and functions should be called from. There really shouldn't be any variable definitions here if you can help it.
The next section is for subroutines. I organized this section by coder so any subroutines a specific individual adds should go in their section. Each name section is separated by a single set of equal sign dividers:
`===========================
The first group is for common variables or code. These are variables or global/universal setup that the entire program will use. Place all variables in this section so that users don't repeat variable names and inadvertently change a value for someone else.
The next section is for functions. This is organized exactly like the subroutine section - by name and a common area (which won't store variables but maybe something like mouse_within() )
The final section is for data statements.
Feel free to use this structure. It may help. As it stands, it needs adjusting so the code runs properly. Each programmer should add any of their code in the form of functions or subroutines. They should call their subroutines from the main section. Check through your section and make sure your code is updated. Add calls from main to make sure it works. Any code you submit should be as an addition or change to this main document. That way, everyone has access the latest updates - and the whole code can be tested. (that means saving this document to your machine, making an update, and posting it in a new message or editing one of your existing messages if it is the last one in the thread)
remstart
==============================================================
= Title : Space Invaders
= Author : Dark Noob Games
= Date : August 9,2010
= Update :
= Version:
==============================================================
Comments
aug 9,2010
The goal of this project is to remake Space Invaders
using DarkBASIC Professional in a team environment
made up of beginner programmers.
The Project Lead is:
The team members are:
==============================================================
remend
rem =============================================================
rem = SET UP DISPLAY
rem =============================================================
autocam off
`set display mode 800,600,32
sync on
sync rate 60
hide mouse
rem =============================================================
rem = MAIN
rem =============================================================
_main:
rem call any setup routines before actually going to the main loop
gosub _variables
gosub _obese_get_images
do
rem daygamer's code
cls
gosub control_player
gosub without_sprites
gosub update_bullets
sync
loop
end
rem =============================================================
rem = SUBROUTINES - PROCEDURES
rem =============================================================
rem ---------------------------------
rem - Shared Code/Varibles
rem ---------------------------------
_variables:
rem by Daygamer
rem this controls if sprites will be used in the game
sprites_on = 0
rem set original player position
playerx = 320
playery = 460
bulletx = 320
bullety = 460
rem draw ship and save it
ink rgb(0,255,0),0
box playerx-20, playery-7, playerx+20, playery+7
box playerx-4, playery-15, playerx+4, playery-7
get image 1,playerx-20, playery-15, playerx+20, playery+15
rem draw bullet and save it
ink rgb(255,255,255),0
line bulletx, bullety-8, bulletx, bullety+8
get image 2,bulletx-1, bullety-8, bulletx+1, bullety+8
`-------------------------------------
rem ajatom variables
`total aliens allowed in the level
maxaliens=41
enemydir=1
return
`================================================================
rem ---------------------------------
rem - Programmer - AJAtom
rem ---------------------------------
rem ajatom
cls
ScrW=screen width()
ScrH=screen height()
makeimage()
gosub enemy_creation
`Main program loop
`***********
backdrop on : color backdrop 0 : sync on : sync rate 60 : do
`***********
gosub enemyprops
enemyplacex=0
enemyplacey=0
`***************
`end main program loop
inc loopcounter,1
sync : loop
`***************
`----------------------------------------------------------------
`************************************
`What I am doing
`************************************
enemy_creation:
`enemy creation
for enemycrt=2 to maxaliens
`creates a new alien
clone sprite 1,enemycrt
show sprite enemycrt
next enemycrt
totalaliens=maxaliens
return
`----------------------------------------------------------------
enemyprops:
for enemy=2 to totalaliens
if sprite exist(enemy)=1
`variables
alieny=sprite y(enemy)
`enemy movement
if loopcounter=50-alienspeed
`moves the enemies over every 50 loops
alienx=sprite x(enemy)+20*enemydir
loopcounter=0
endif
`checks to see if aliens have reached the right side of the screen
if sprite x(totalaliens)>=ScrW-Sprite width(totalaliens) and enemydir=1
inc alienspeed,4
flag=1
enemydir=-1
endif
`checks to see if aliens have reached the left side of the screen
if sprite x(2)<=0+sprite width(enemy) and enemydir=-1
inc alienspeed,4
flag=1
enemydir=1
endif
`enemy shoot
if loopcounter=10
interval=rnd(20)
if interval=1
sniper=enemy
bulletactive=1
endif
endif
`enemies get drawn
if flag=1 : inc newalieny,Sprite height(enemy)+10 : flag=0 : endif
sprite enemy,alienx+enemyplacex,enemyplacey+newalieny,1
`creates new column of enemies
if sprite y(enemy)>100+newalieny
inc enemyplacex,50
enemyplacey=0
else
`spaces aliens apart
inc enemyplacey,50
endif
endif
next enemy
if bulletactive=1 then gosub alienshot
return
`----------------------------------------------------------------
alienshot:
if bulletlife=0
rem draws the line at the nose of the shooting enemy
linex=sprite x(sniper)+sprite width(sniper)/2
liney=sprite y(sniper)+sprite height(sniper)
endif
bulletlife=1
ink -1,0
`draws moving line
line linex,liney+shoty,linex,(liney+25)+shoty
inc shoty,7
`deactivates shot
if shoty>ScrH*2
shoty=0
bulletlife=0
bulletactive=0
endif
return
`************************************
`================================================================
rem ---------------------------------
rem - Programmer - Shadow
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - Daygamer
rem ---------------------------------
rem space invaders
rem player movement and firing (medialess)
rem 8/9/10
rem control player >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
control_player:
rem controls for moving player side to side
rem it will not let the player move out of the screen
if playerx < 600 and rightkey()=1 then inc playerx, 2
if playerx > 40 and leftkey()=1 then dec playerx, 2
rem store fire key input
oldfire = newfire
newfire = spacekey()
rem fire bullet if none exists
if newfire > oldfire
if bullet_fired = 0
bullet_fired = 1
rem position the bullet at the ship's position
bullety = playery-20
bulletx = playerx
endif
endif
return
`----------------------------------------------------------------
rem draw objects without using sprites >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
without_sprites:
rem set ink green for ship
ink rgb(0,255,0),0
rem draw player ship
paste image 1,playerx-20, playery-11
rem set ink white for bullet
ink rgb(255,255,255),0
rem draw the bullet
if bullet_fired
paste image 2,bulletx, bullety
endif
return
`----------------------------------------------------------------
rem update bullets >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
update_bullets:
rem update player bullet
if bullet_fired
dec bullety, 7
rem if bullet passes out of screen it dies
if bullety < 0 then bullet_fired = 0
endif
return
`================================================================
rem ---------------------------------
rem - Programmer - Eminent
rem ---------------------------------
rem eminent
Rem Project: Menu
Rem Created: Monday, August 09, 2010
Menu:
Rem ***** Main Source File *****
set text font "Ariel"
Set text size 30
`Set Sound Volume 1, 50 unrem this and delete this message when installing in main program
`Set Music Volume 1, 50 same as above
sw = screen width()` just in case
sh= screen height()
Repeat
CLS
Click = 0
Box 100,50,700,150, rgb(0,0,255), rgb(0,0,255), rgb(0,0,255), rgb(0,0,255)
Center Text 350, 85, " Play Space Invaders"
Box 100, 300, 700, 400, rgb(255,0,0), rgb(255,0,0), rgb(255,0,0), rgb(255,0,0)
Center Text 350, 335, "Exit"
Box 10, 500, 150, 550, rgb(175,175,175), rgb(175,175,175), rgb(175,175,175), rgb(175,175,175)
Center text 70, 505, "Settings"
If mouseclick() = 1 and Click = 0
If mouseWithin(100,50,700,150) and Click = 0 ` testing stuff, dont mind the "and click = 0" part
Done = 1
Click = 1
endif
Endif
If mouseclick() = 1 and Click = 0
If mouseWithin(100, 300, 700, 400) and Click = 0
end
endif
Endif
If mouseclick() = 1 and Click = 0
if mousewithin(10,500,150,550) and Click = 0
Gosub Settings
endif
endif
Until Done = 1
`----------------------------------------------------------------
Playing:
do
cls
Print "Wow this is fun" ` to be replaced with the actual playing
if keystate(25) = 1
Gosub Pause
endif
loop
`----------------------------------------------------------------
Settings:
CLS
Dim ScreenRes(6) ` again just in case
ScreenRes(1) = 640
ScreenRes(2) = 480
ScreenRes(3) = 800
ScreenRes(4) = 600
ScreenRes(5) = 1024
ScreenRes(6) = 768
repeat
CLS
Set text size 30
Box 50,10,700,70, RGB(175,175,175), RGB(175,175,175), RGB(175,175,175), RGB(175,175,175)
Text 70, 20, "Screen Resolution Press E to exit or press shiny blue button."
Box 50,140,700,200, RGB(200,0,0), RGB(200,0,0), RGB(200,0,0), RGB(200,0,0)` the boxes
Box 50,270,700,330,RGB(255,255,0),RGB(255,255,0),RGB(255,255,0),RGB(255,255,0)
Box 50,400,700,460,RGB(0,255,0),RGB(0,255,0),RGB(0,255,0),RGB(0,255,0)
Box 200,500,600,599,RGB(0,0,255),RGB(0,0,255),RGB(0,0,255),RGB(0,0,255)
Center Text 150,150, "640x480x32"
center text 150,280, "800x600x32"
center text 150,410, "1024x768x32"
center text 350, 540, "Main Menu"
If keystate(18) = 1
exit
endif
If MouseWithin(50,140,700,200) and mouseclick() = 1 ` better way to do it
Set Display Mode ScreenRes(1), ScreenRes(2), 32
ScreenPrintTest$ = "640x480x16" ` testing to see if mousewithin function is working properly
Endif
If MouseWithin(50,280,700,340) and mouseclick() = 1
Set Display Mode ScreenRes(3), ScreenRes(4), 32
ScreenPrintTest$ = "800x600x16"
endif
If MouseWithin(50,400,700,460) and mouseclick() = 1
Set Display Mode ScreenRes(5), ScreenRes(6), 32
ScreenPrintTest$ = "960x720x16"
endif
If Mousewithin(200,500,600,599) and MouseClick() = 1
Exit1 = 1
endif
until Exit1 = 1
Return
`----------------------------------------------------------------
Pause:
thumbX= 250
Volume# = 50
Repeat
BOX 80,50,500,250, RGB(255,0,0), RGB(255,0,0), RGB(255,0,0), RGB(255,0,0)
Text 90, 60, "Volume"
Text 90, 100, "0"
Text 400, 100, "100"
Text 90, 200, "Press spacebar to continue"
if mouseclick() = 1 and CFlag = 0 ` ooooooohhhhhhhhhh a slider :D
squaredDistance = (mousex() - thumbX)^2 + (mousey() - 100)^2
if squaredDistance <= 16 and CFlag = 0
thumbClicked = 1
offsetX = mousex() - thumbX
CFlag = 1
endif
CFlag = 1
endif
if mouseclick() = 0
CFlag = 0
thumbClicked = 0
endif
if thumbClicked = 1
thumbX = mousex() - offsetX
if thumbX < 100 then thumbX = 100
if thumbX > 400 then thumbX = 400
Volume# = (thumbX - 100) / 3
endif
ink rgb(255,255,255),0
line 100,100,400,100
ink rgb(0,255,0),0
circle thumbX, 100, 4
`set music volume 1, Volume# un rem when installing in code
`set sound volume 1, Volume#
if keystate(57) = 1
Exit2 = 1
endif
Text 190, 60, str$(Volume#)
until
return
`================================================================
rem ---------------------------------
rem - Programmer - xxelixx
rem ---------------------------------
rem ---------------------------------
rem - Programmer - Obese87
rem ---------------------------------
_obese_setup:
secsize = 40 : rem make a variable to store the size of the sections so we can change it easily when needed.
gosub get_images
rem store the barrier section data in an array. This will tell us how damaged each section is and so which image to use.
rem The first 8 barriers are in the first barrier, the second 8 in the second and so on. The sprite numbers are the same.
dim barrdam(32)
rem divide screen by five, not four, because we want to place the barriers on points in-between the two sides of the screen (0-1-2-3-4-5)
divw# = screen width()/5.0
rem set the y position based on screen height
posy = screen height()*.75
rem by offsetting the barrier we centre it in the right place
bxoffset = 2*secsize
rem build the barriers
for barr = 0 to 3
for sec = 1 to 8
if sec > 4
x = (barr+1)*divw#+(sec-4)*secsize-bxoffset
y = posy+secsize
else
x = (barr+1)*divw#+sec*secsize-bxoffset
y = posy
endif
sprite barr*8+sec, x, y, barrdam(barr*8+sec)
next sec
next barr
return
`end
`----------------------------------------------------------------
`//
_obese_get_images:
rem These are the 32 images placeholder image; each of the eight sections has a unique image
rem and each section needs four images to show damage condition (8x4 = 32)
rem These images will just be one colour and each section will look the same, but they are just placeholders remember.
for dam = 0 to 3
rem select a different colour for each damage level
select dam
case 0 : colour=65535 : endcase
case 1 : colour=rgb(255,255,0) : endcase
case 2 : colour=rgb(255,128,0) : endcase
case 3 : colour=rgb(255,0,0) : endcase
endselect
ink colour,0
box 0,0,secsize,secsize
for sec = 1 to 8
get image dam*8+sec,0,0,secsize,secsize
next sec
next dam
return
`================================================================
rem ---------------------------------
rem - Programmer - BN2
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - sinani
rem ---------------------------------
`================================================================
rem =============================================================
rem = FUNCTIONS
rem =============================================================
rem ---------------------------------
rem - Shared Code/Varibles
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - AJAtom
rem ---------------------------------
function makeimage()
`will be replaced by alien graphic
`************************
create bitmap 1,25,25
ink rgb(255,0,0)
box 0,0,25,25
get image 1,0,0,25,25
delete bitmap 1
sprite 1,50,40,1 : hide sprite 1
`************************
endfunction
`================================================================
rem ---------------------------------
rem - Programmer - Shadow
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - Daygamer
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - Eminent
rem ---------------------------------
function mouseWithin(x1,y1,x2,y2)` this is very useful
mx = mousex()
my = mousey()
if mx>=x1 and mx<=x2 and my>=y1 and my<=y2 then exitfunction 1 `self explanatory
endfunction 0
`================================================================
rem ---------------------------------
rem - Programmer - xxelixx
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - Obese87
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - BN2
rem ---------------------------------
`================================================================
rem ---------------------------------
rem - Programmer - sinani
rem ---------------------------------
`================================================================
rem =============================================================
rem = DATA STATEMENTS
rem =============================================================
Enjoy your day.