Wow, you guys have come pretty far. I might have a go at programming one of these, tomorrow morning anyway..
edit: ok, afternoon my time... it's nowhere near done, but it is modularized... I'm gonna add the menu system I made earlier to it, but for now I keep it short. I'm posting this for a reason though,
`my personal goal is to make this as dynamically editable as
`can be, using ini files and similar more than code.
`for loading enemies, players, even types of gameplay
`INITIALIZATION
sync on
sync rate 32
set image colorkey 255,255,255
`white is the new black... or nonexistant anyway
`Load images
load image "Player.bmp", 1
`VARIABLE DECLARATION
global gameState as integer
global stateGame as integer
global stateMenu as integer
global level as integer
`Entity variables
global player as integer
`global playerx as integer
`global playery as integer COMMENTED OUT SEE BELOW
`playerHealth and XY will be fly(1)'s value... since fly(1) = player. (fly(player), in the AI control)
global playerSpeed as integer
`calling entities flies now, heh, 'cause they're ships
`also the fly(500) index will be the entity, and the integer will
`be its health, for clean efficient code
`THE REASON UDT'S ARE NOT USED IS BECAUSE THEY CAN'T BE PASSED INTO A FUNCTION
global dim fly(500) as integer
global dim flyx(500) as integer
global dim flyy(500) as integer
global dim flyactive(500) as integer
global dim flyimg(500) as integer
global dim flywidth(500) as integer
global dim flyheight(500) as integer
global dim flyAI(500) as integer
`flyAI is really the flyAI type, which determines how the ship behaves
global aiTypePlayer as integer
global aiTypeBasic as integer
`VARIABLE ASSIGNING
for c = 1 to 500
`starting health = 200 for now
fly(c) = 200
flyx(c) = -860
`initializing all object above the window in center
`assuming 800 by 600
flyy(c) = -900
`initializing all objects as inactive, might change later
`also might not even be used
flyactive(c) = 0
`just noticed, if you paste images that are above the screen, then they
`just paste to the upper left hand corner, so I need this variable to tell
`if they're active or not for the displayFly() function
`flyimg is which image the Fly's should use, 1 is player by default
flyimg(c)=1
next c
player = 1
playerSpeed = 9
`enumerate AI types
aiTypePlayer = 0
aiTypeBasic = 1
`Enumeration of state of game
stateGame = 1
stateMenu = 2
`The basic starting level lest a save file is used
level = 1
`PreMain Assigning
flyx(player) = 368
flyy(player) = 522
flyactive(player) = 1
gameState = stateGame
`MAIN```````````````````````````````
do
cls
if gameState = stateMenu then menuFunction()
if gameState = stateGame then doMainGame()
SYNC
loop
`````````END MAIN```````````````
`FUNCTION DEFINITION
`THE MENU
function menuFunction()
endfunction
`THE GAME STATE
function doMainGame()
`update every fly()'s movement
AIfunction()
`render the understuff first...
doBackground()
`gotta render to the screen
displayFly()
endfunction
`The artificial Intelligence function is responsible for ALL entities, even the player
`the goal is to modularize all types of AI for every ship... so you can plug in a ship
`say it's a "fighter" and it'll automatically act like a fighter through a config variable
`this is why the player is no different it is "an entity set to act like the player"
function AIfunction()
for count = 1 to 500
if flyActive(count) > 0
doFlyMoveAI( count, flyAI(count) )
endif
next count
endfunction
`Within the AI, this function obtains the player's movement controls
function playerMovement()
if keystate( 17 ) then flyy(player) = flyy(player) - PlayerSpeed
if keystate( 30 ) then flyx(player) = flyx(player) - playerSpeed
if keystate( 31 ) then flyy(player) = flyy(player) + PlayerSpeed
if keystate( 32 ) then flyx(player) = flyx(player) + playerSpeed
keepPlayerInside()
endfunction
function keepPlayerInside()
if flyx(player) > 744 then flyx(player) = 744
if flyx(player) < 0 then flyx(player) = 0
if flyy(player) > 544 then flyy(player) = 544
if flyy(player) < 0 then flyy(player) = 0
endfunction
`RENDER THE FLIES to the screen!
function displayFly()
for c = 1 to 500
` if flyactive(c) > 0 then
paste image flyimg(c), flyx(c), flyy(c)
next c
endfunction
`HANDLE THE MOVEMENT OF EVERY FLY, AI STYLE
function doFlyMoveAI(flynum, aiStyle)
`flynum is the index of the fly, aiStyle determines how it should move
`admittedly playerMovement isn't following along in the same style as the other
`entities, because at some point I'll need to grab the input, so I left it as is
if aiStyle = aiTypePlayer then playerMovement()
`aiTypeBasic just moves the entity forward, and will shoot if I add shooting
`to this, or another AI command, like BulletAI, unsure how as of yet
if aiStyle = aiTypeBasic
flyy(flynum) = flyy(flynum) + 6
endif
endfunction
`this function displays the background, it is separate so you can load
`any sort ot thing, from an image to a map, for any occastion
`I suggest using a switch, and doing stuff like if BOSS then use BG_BOSS_1 or something
`there will need to be information based on level, and if you're at the boss or not
function doBackground()
endfunction
I've read your code, and you guys rely a ton on "hardcoded" stuff, since you're tightly-knit grouped on this forum. Notice how my code shoves everything into the smallest logical area, then tightly packs it away in some area. PlayerAI simply being the input, and btw read my comment regarding the AI system I'm about to put into it... it's designed to where you say "enemy x is this, it's ai type is 5" and that's all you have to do.
Of course, I have yet to put in the file loader and take out the hardcoded stuff (only a couple hours into coding this so far), but it is already ready to be switched on over, since my "player load" functions have absolutely nothing to do with my "player move", nor even the "player image", which gets dynamically loaded into the array.
In other words, with very few lines of code, if you write it dynamically, you can use ini files and do the rest without needing to recompile. This should be your goals as a new project team. Also, just make a 64 by 64 image and you can run my simple demonstration.
Omen's on break, and I need to code this for my own work anyway, so I thought I'd hop in and see if I could contribute a bit. Also, I'd bet you can clean my code further if you try. Just unsure how, or I would do it right now, lol. Now to work on the file system so it can do the dynamic stuff I'm explaining... will upload code later so you can see.
-----------------
EDIT: Instead of double posting, here's my 2nd major edit...->
`this is a basic shooter, intended to be modular
`and use C++ style code
`my personal goal is to make this as dynamically editable as
`can be, using ini files and similar more than code.
`for loading enemies, players, even types of gameplay
`INITIALIZATION
sync on
sync rate 32
set image colorkey 255,255,255
`white is the new black... or nonexistant anyway
`Load images
load image "Player.bmp", 1
`VARIABLE DECLARATION
global gameState as integer
global stateGame as integer
global stateMenu as integer
global level as integer
global enemyFlyCount as integer
`Entity variables
global player as integer
`global playerx as integer
`global playery as integer COMMENTED OUT SEE BELOW
`playerHealth and XY will be fly(1)'s value... since fly(1) = player. (fly(player), in the AI control)
global playerSpeed as integer
`calling entities flies now, heh, 'cause they're ships
`also the fly(500) index will be the entity, and the integer will
`be its health, for clean efficient code
`THE REASON UDT'S ARE NOT USED IS BECAUSE THEY CAN'T BE PASSED INTO A FUNCTION
global dim fly(500) as integer
global dim flyx(500) as integer
global dim flyy(500) as integer
global dim flyactive(500) as integer
global dim flyimg(500) as integer
global dim flywidth(500) as integer
global dim flyheight(500) as integer
global dim flyAI(500) as integer
`flyAI is really the flyAI type, which determines how the ship behaves
global aiTypePlayer as integer
global aiTypeBasic as integer
`VARIABLE ASSIGNING
for c = 1 to 500
`starting health = 200 for now
fly(c) = 200
flyx(c) = -860
`initializing all object above the window in center
`assuming 800 by 600
flyy(c) = -900
`initializing all objects as inactive, might change later
`also might not even be used
flyactive(c) = 0
`just noticed, if you paste images that are above the screen, then they
`just paste to the upper left hand corner, so I need this variable to tell
`if they're active or not for the displayFly() function
`flyimg is which image the Fly's should use, 1 is player by default
flyimg(c)=1
next c
player = 1
playerSpeed = 9
`enumerate AI types
aiTypePlayer = 0
aiTypeBasic = 1
`Enumeration of state of game
stateGame = 1
stateMenu = 2
`The basic starting level lest a save file is used
level = 1
`PreMain Assigning
flyx(player) = 368
flyy(player) = 522
flyactive(player) = 1
`CHANGE THIS DURING TESTING ALONE
gameState = stateMenu
`MAIN```````````````````````````````
do
cls
if gameState = stateMenu then menuFunction()
if gameState = stateGame then doMainGame()
SYNC
loop
`````````END MAIN```````````````
`FUNCTION DEFINITION
`THE MENU
function menuFunction()
print "Press spacebar to begin!"
if spacekey()
doLoadLevel(level)
gameState = stateGame
endif
endfunction
`THE GAME STATE
function doMainGame()
`developer's note: it seems this function is independent of what level is
`currently loaded. This might be a problem, or it might be OK, will find out
`when I load a few levels after I get the switch-level code in here.
`update every fly()'s movement
AIfunction()
`render the understuff first...
doBackground()
`gotta render to the screen
displayFly()
endfunction
`The artificial Intelligence function is responsible for ALL entities, even the player
`the goal is to modularize all types of AI for every ship... so you can plug in a ship
`say it's a "fighter" and it'll automatically act like a fighter through a config variable
`this is why the player is no different it is "an entity set to act like the player"
function AIfunction()
for count = 1 to 500
if flyActive(count) > 0
doFlyMoveAI( count, flyAI(count) )
`see if anything is below the bottom, make it deactivated
checkBelow()
endif
next count
endfunction
`Within the AI, this function obtains the player's movement controls
function playerMovement()
if keystate( 17 ) then flyy(player) = flyy(player) - PlayerSpeed
if keystate( 30 ) then flyx(player) = flyx(player) - playerSpeed
if keystate( 31 ) then flyy(player) = flyy(player) + PlayerSpeed
if keystate( 32 ) then flyx(player) = flyx(player) + playerSpeed
keepPlayerInside()
endfunction
function keepPlayerInside()
if flyx(player) > 744 then flyx(player) = 744
if flyx(player) < 0 then flyx(player) = 0
if flyy(player) > 544 then flyy(player) = 544
if flyy(player) < 0 then flyy(player) = 0
endfunction
`RENDER THE FLIES to the screen!
function displayFly()
for c = 1 to 500
` if flyactive(c) > 0 then
paste image flyimg(c), flyx(c), flyy(c)
next c
endfunction
`HANDLE THE MOVEMENT OF EVERY FLY, AI STYLE
function doFlyMoveAI(flynum, aiStyle)
`flynum is the index of the fly, aiStyle determines how it should move
`admittedly playerMovement isn't following along in the same style as the other
`entities, because at some point I'll need to grab the input, so I left it as is
if aiStyle = aiTypePlayer then playerMovement()
`aiTypeBasic just moves the entity forward, and will shoot if I add shooting
`to this, or another AI command, like BulletAI, unsure how as of yet
if aiStyle = aiTypeBasic
flyy(flynum) = flyy(flynum) + 6
endif
`Lastly, make sure all AI ships are on-screen X-coordinate wise
doAIBoundingCheck(flynum)
endfunction
`this function displays the background, it is separate so you can load
`any sort ot thing, from an image to a map, for any occastion
`I suggest using a switch, and doing stuff like if BOSS then use BG_BOSS_1 or something
`there will need to be information based on level, and if you're at the boss or not
function doBackground()
endfunction
function doLoadLevel(lvl)
lname as string
lname = "level" + STR$(lvl) + ".txt"
`for good measure, gonna deactivate all entities except player
DeActivateFlies()
enemyFlyCount = 1
open to read 1, lname
`my parser is extremely basic, will use tokens in the near future hopefully
`though it does allow comments so long as the start of a string isn't a keyword!
while file end(1)=0
read string 1, instring$
if left$(instring$, 5) = "group" then doParseGroup()
`endif
endwhile
close file 1
endfunction
`this function will deactivate anything that's well below the assumed 800
`by 600 area. This saves time for collision and other functions, even display
function checkBelow()
for count = 2 to 500
if flyy(count) > 1050 then flyactive(count) = 0
next count
endfunction
function doParseGroup()
`t = temp... for naming conventions
`image type (1 = player's for tests)
read string 1, instring$
timg = VAL(instring$)
`number of ships
read string 1, instring$
tflyarray = VAL(instring$)
`starting X values
read string 1, instring$
txStart = VAL(instring$)
`starting Y values
read string 1, instring$
tyStart = VAL(instring$)
`spacing between them in pixels (speed is handled by AI type)
read string 1, instring$
tspacing = VAL(instring$)
`style of AI
read string 1, instring$
tAItype = VAL(instring$)
`gotta make sure to activate and update everyone EXCEPT player
for temp = 1 to tFlyArray
`negative to encourage ships to come after, not before indicated spot
enemyFlyCount = enemyFlyCount + 1
flyActive(enemyFlyCount) = 1
flyx(enemyFlyCount) = txStart
flyy(enemyFlyCount) = tyStart + tspacing * temp * (-1)
flyAI(enemyFlyCount) = tAItype
next temp
endfunction
`keep those bugs on the screen! AI itself might shove them off otherwise
function doAIBoundingCheck(flynumbr)
`it is now apparent I will need to add flywidth and height sooner than I
`expected in order to have clean code most of the way through... this for now
`assumes 64 by 64 pixel images, which I can't always do
if flyx(flynumbr) < 0 then flyx(flynumbr) = 0
if flyx(flynumbr) > 744 then flyx(flynumbr) = 744
endfunction
function DeActivateFlies()
for count = 2 to 500
flyactive(count) = 0
next count
endfunction
Create an ini file to go with it, fill it with this or similar:
keyword(s): group
that keyword has its next lines as image, ship count, x, y, spacing, and AIType in that order
....player AI is 0 and basic is 1, to start
group
1
5
50
-100
88
1
group
1
8
340
-99
125
1
I'll upload my basic player image here (it's a P, guess why lol).. ok did that... (in case you think that's faster anyway)
shove Player.bmp in the dir, also create level1.ini (the code already supports more than one of those files, but has yet to add switching in), and compile.
That will be all I'll hand out here, from this point on I'm rewriting my own software commercially to make a worthy version of kana blaster (right now it's a clicker... not blaster), so now you know why I did this almost randomly.
BUT! I'm still willing to help out. It's fully modularized now and add a couple gfx and one or two more AI types in there (which is easy, plug 'n chug at this point) and you'll have a ready to go engine for this (minus the bullet system anyway). (yes I know I also need more image types, but even that's just adding an array and there you go. From this point on, it should be a breeze (if my bugs are small... heh)
Have fun you guys,
Signed
------