OK, I know it is kind of silly posting an unfinished project's sourcecode, but I'd like to share with you some of my ideas.
It is my way to say "thanks for the support" to everyone who patiently and effectively answered every single silly question I've made and improved my knowledge enough to provide me means to accomplish my stuff.
This is a sourcecode full of trash. Yeah, there are tons of unused functions that are not called by the main loop. I could remove them, but I don't want to remake the code, I just want to show you what I am doing.
It runs OK and - yeah - it has no media requirements, it doesn't rely on external files of any sort - and it is... well, let me explain:
I am making a fantasy retro shooter-rpg whatever game (the genre doesn't exist, so I don't know how to name it properly).
So, I made the algorithm to generate retro-like spaceships and its weapons, and I produced a main loop just to list all the 5 quintillion ships my game will use with their respective 5 quintillion weapons. I know, the variation is merely cosmetic, but the idea is not making zillions of completely different stuff, it is to make a zillion not-so-different stuff, it is just for the sake of fun!
If you want to compile it, it is already set up to detect and configure its resolution to match your desktop, and it uses fake fullscreen to avoid bugs when changing to real fullscreen.
Use UP and DOWN to zip through the whole ship catalogue, CTRL+UP and CTRL+DOWN to perform it faster - as fast as your computer can generate a new ship and weapon (for my Core 2 Due it takes about 0.1 second). LEFT key performs a small zoom out and RIGHT key performs a slight zoom in.
Enjoy and give me feedback if possible!
type shot_atb
level as integer
color as integer
height as integer
width as integer
angle as integer
amount as integer
velocity as float
STYLE AS BYTE
SCROLLX AS FLOAT
SCROLLY AS FLOAT
range as byte
endtype
dx = desktop width() : dy = desktop height() : dp = 32
set display mode dx,dy,dp : maximize window : set window layout 0,0,0
autocam off
set global collision on
sync on
sync rate 60
global seed as double integer
do
randomize seed
//preparegrid(1000)
w = rnd(5)+3 : h = rnd(5)+3
R = (RND(2)*125)
G = (RND(2)*125)
B = (RND(2)*125)
c = RGB(R+5,G+5,B+5)
w = rnd(5)+7 : h = rnd(w)+(w/2)
makeship(1,w,h)
l = -4 : K = RND(3)
makeshot(2,w,h,c,l,K)
glue object to limb 2,1,0
hide object 2
p = 1001
color backdrop 0
amt = rnd(5)+1 : ang = rnd(359)
SX# = (RND(9)*0.01)-(RND(9)*0.01)
SY# = (RND(9)*0.01)-(RND(9)*0.01)
v as float
v = (rnd(15)+1)*0.125
cadence = rnd(1500)+500
text_obj(5,str$(seed),"Lucida console",30) : scale object 5,15,20,100 : lock object on 5 : position object 5,0,-10,25 : pitch object up 5,60
set spot light 0,20,30 : position light 0,0,0,-50
repeat
point light 0,sin((timer()/10) mod 360)*15,cos((timer()/10) mod 360)*15,0
IF K > 0 THEN SCROLLSHOT(2,SX#,SY#)
//move object up 1,upkey() - downkey()
position camera 0,object position x(1),object position y(1),30 + (leftkey()*20)-(rightkey()*10) : point camera 0,object position x(1),object position y(1),0
if t < timer() : SHOOT(1,amt,ang) : t = timer() + cadence : endif
MOVESHOT(1,v)
sync
seed = wrap(seed+upkey()-downkey(),0,5000000000000000)
until upkey() = 1 or downkey() = 1
sleep (250-(controlkey()*250))+1 : t = 0
for x = 1 to 200
if object exist(x) = 1 then delete object x
next x
Loop
function shipimg(n,w,h)
create bitmap n,w+1,h+1
cls 0
x = w : y = int(h/2)
s = (w*h)*2 : rw = x
rw = x : uh = y : dh = y
lock pixels
repeat
v = 105 + (rnd(5)*30)
c = rgb(v,v,v)
if x < rw then rw = x
if y < uh then uh = y : if y > dh then dh = y
dot x,y,c
d = rnd(3)
if d = 0 and x > 1 then dec x
if d = 1 and x < w then inc x
if d = 2 and y > 1 then dec y
if d = 3 and y < h then inc y
dec s
Until s = 0
unlock pixels
if image exist(n) = 1 then delete image n
get image n,rw-1,0,w+1,h+1,1
delete bitmap n
Endfunction
function makeship(o,w,h)
if object exist(o) = 1 then delete object o
make object plane o,w*2,h
set object light o,1
shipimg(o,w,h)
texture object o,o
set object texture o,2,1
set object transparency o,1
set object filter o,0
scale object texture o,2,1
C1 = RGB((RND(4)*50)+55,(RND(4)*50)+55,(RND(4)*50)+55)
C2 = RGB((RND(4)*50)+55,(RND(4)*50)+55,(RND(4)*50)+55)
SET oBJECT DIFFUSE o,C1
SET oBJECT SPECULAR o,C2
SET oBJECT SPECULAR POWER o,RND(255)
//set object ambient o,255
endfunction
function drawshot(n,w,h,color)
create bitmap n,w+1,h+2
cls 0
sx = rnd(1)+1 : sy = rnd(1)+1
rv = rnd(1)+1
lock pixels
for x = 1 to w step sx
for y = 1 to h step sy
if rnd(rv) > 0 then dot x,y,color
next
Next
unlock pixels
if image exist(n) = 1 then delete image n
get image n,0,0,w+1,h+2,1
delete bitmap n
Endfunction
function makeshot(n,w,h,color,level,K)
drawshot(n,w,h,color)
if object exist(n) = 1 then delete object n
IF K = 0 THEN make object PLANE n,(w*2)+level,h+level
IF K = 1 THEN make object SPHERE n,(w*2)+level
IF K = 2 THEN make object CONE n,h+level
IF K = 3 THEN make object CYLINDER n,(w*2)+level
texture object n,n
set object texture n,2,1
IF K = 0 THEN scale object texture n,2,1 ELSE scale object texture n,2^(RND(2)+1),2^(RND(2)+1)
IF K > 0 THEN SCALE OBJECT TEXTURE n,RND(99)+1,RND(9)+1,RND(9)+1
set object filter n,RND(1)+1
SET OBJECT CULL n,0
set object transparency n,1
set object light n,0
set object collision to spheres n
Endfunction
function replace(o,os)
ox = object position x(os) : oy = object position y(os) : oz = object position z(os)
oax = object angle x(os) : oay = object angle y(os) : oaz = object angle z(os)
position object o,ox,oy,oz : rotate object o,oax,oay,oaz
if object exist(o) = 1 AND object exist(os) = 1
Endif
Endfunction
FUNCTION SHOOT(n,AMOUNT,ANGLE)
if AMOUNT > 1
A_STEP = INT(ANGLE/(AMOUNT-1))
A_HALF = int(ANGLE/2)
FOR O = 1 TO AMOUNT
OBJ = FINDFREE(n*100,99)
INSTANCE OBJECT OBJ,n+1
REPLACE(OBJ,n)
ROLL OBJECT left OBJ,wrapvalue(A_HALF-(A_STEP*(O-1)))
NEXT
else
obj = findfree(n*100,99)
instance object obj,n+1
replace(obj,n)
endif
Endfunction
FUNCTION FINDFREE(ST,RANGE)
for o = ST to ST+RANGE
IF OBJECT EXIST(o) = 0 : obj = 0 : exit : endif
Next o
Endfunction O
FUNCTION MOVESHOT(n,v as float)
FOR X = n*100 TO (n*100) + 99
IF OBJECT EXIST(X) = 1
MOVE OBJECT UP X,v
RANGE = (15 + rnd(85))
asize = 2000
if DISTANCE(n,X) > RANGE OR object position x(x) < -asize or object position x(x) > asize or object position y(x) < -asize or object position y(x) > asize then delete object x
endif
Next
Endfunction
FUNCTION STAR(IMG,size,COLOR)
if object exist(IMG) = 1 then delete object IMG
if image exist(IMG) = 1 then delete IMage IMG
IF COLOR = 0 : C1 = RGB(255,127,0) : C2 = RGB(255,255,0) : ENDIF
IF COLOR = 1 : C1 = RGB(0,255,255) : C2 = RGB(255,255,255) : ENDIF
IF COLOR = 2 : C1 = RGB(200,0,0) : C2 = RGB(255,100,0) : ENDIF
IF COLOR = 3 : C1 = RGB(255,255,255) : C2 = RGB(200,200,255) : ENDIF
IF COLOR = 4 : C1 = RGB(230,100,0) : C2 = RGB(255,200,0) : ENDIF
IF COLOR = 5 : C1 = RGB(30,0,0) : C2 = RGB(255,127,0) : ENDIF
w = 20 : h = 10
CREATE BITMAP IMG,W,H
s = (w*h)/2
cls c1
LOCK PIXELS
c = 0
repeat
x = rnd(w) : y = rnd(h)
dot x,y,C2
inc c
Until c = s
UNLOCK PIXELS
get image IMG,0,0,w,h,1
DELETE BITMAP IMG
make object sphere IMG,size
texture object IMG,IMG
SET OBJECT TEXTURE IMG,2,1
SC = RND(5)+1
SCALE OBJECT TEXTURE IMG,SC,SC
set object filter IMG,2
set object light IMG,0
//SET SPOT LIGHT 0,360,360
set point light 0,0,0,0
SET LIGHT RANGE 0,3000
//COLOR light 0,c2
ENDFUNCTION
FUNCTION STAR_ATM(OBJ)
sx# = (rnd(100) * 0.01) - (rnd(100) * 0.01)
sy# = (rnd(100) * 0.01) - (rnd(100) * 0.01)
scroll object texture OBJ,sx#,sy#
POINT LIGHT 0,OBJECT POSITION X(OBJ),OBJECT POSITION Y(OBJ),OBJECT POSITION Z(OBJ)
POSITION LIGHT 0,OBJECT POSITION X(OBJ),OBJECT POSITION Y(OBJ),OBJECT POSITION Z(OBJ)
Endfunction
FUNCTION _planet(obj,size,CLASS,RING)
if CLASS = 0
//hot rocky
mass = (rnd(3)*25)+25
color1= rgb(50+rnd(205),50+rnd(205),0)
color2= rgb(50+rnd(205),50+rnd(205),0)
Endif
if CLASS = 1
//terra
mass = (rnd(3)*25)+25
color1 = rgb(0,rnd(127),rnd(127)+127)
color2 = rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1)
Endif
if CLASS = 2
//frozen giant
mass = (rnd(3)*25)+25
color1 = rgb(230+rnd(25),230+rnd(25),230+rnd(25))
color2 = rgb(127+rnd(127),127+rnd(127),127+rnd(127))
Endif
if CLASS = 3
//gas giant
mass = (rnd(2)*25)+50
color1 = rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1)
color2 = rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1)
Endif
if CLASS = 4
//luna
mass = rnd(95)+5
co1 = rnd(100)+155 : co2 = rnd(254)+1
color1 = rgb(co1,co1,co1)
color2 = rgb(co2,co2,co2)
Endif
W = size : H = size/2
CREATE BITMAP obj,W,H
CLS COLOR1
LOCK PIXELS
mass = 30+mass
L = 0 : LM = CEIL((W*H)/2) * (0.01 * mass)
REPEAT
X = RND(W) : Y = RND(H) : DOT X,Y,COLOR2 : inc l
Until L = LM
UNLOCK PIXELS
if image exist(obj) = 1 then delete image obj
if image exist(obj+1) = 1 then delete image obj+1
if CLASS = 3 then get image obj,0,0,1,h,1 else GET IMAGE obj,0,0,W,H,1 : DELETE BITMAP obj
if w < 10 then w2 = 10 else w2 = w
if h < 6 then h2 = 6 else h2 = h
if object exist(obj) = 1 then delete object obj
if object exist(obj+1)=1 then delete object obj+1
MAKE OBJECT SPHERE obj,size,W2,H2
TEXTURE OBJECT obj,obj
SET OBJECT FILTER obj,2
if RING = 1
WR = W*2.5
CREATE BITMAP obj+1,1,WR
cr1 = rgb(rnd(127)+127,rnd(127)+127,rnd(127)+127)
cr2 = rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
LOCK PIXELS
cls 0
RI = WR/4.5
RS = RND(RI) : RE = RND(RI)
for r = (WR/2) + RS TO WR - RE
RT = RND(3)
if RT = 2 then LINE 0,R,2,R,cr1
IF RT = 3 THEN LINE 0,R,2,R,CR2
Next
UNLOCK PIXELS
get image obj+1,0,0,1,bitmap height(obj+1),1
delete bitmap obj+1
make OBJect sphere obj+1,W*2.5,2,24
scale OBJect obj+1,100,1,100
texture OBJect obj+1,obj+1
set OBJect texture obj+1,2,1
scale OBJect texture obj+1,1,2
set OBJect transparency obj+1,1
set OBJect cull obj+1,0
SET OBJECT FILTER obj+1,0
SET ALPHA MAPPING ON obj+1,25+(RND(3)*25)
glue OBJect to limb obj+1,obj,0
Endif
Endfunction
function crate(n)
w = rnd(5)+3 : h = rnd(5)+3
create bitmap n,w,h
c1 = rgb(rnd(255),rnd(255),rnd(255))
c2 = rgb(rnd(255),rnd(255),rnd(255))
sx = rnd(1)+1 : sy = rnd(1)+1
mx = rnd(4)+2 : my = rnd(4)+2
cls 0
lock pixels
for x = 0 to w step sx
for y = 0 to h step sy
if x mod mx = 0 xor y mod my = 0 then dot x,y,c1 else if rnd(1) = 0 then dot x,y,c2
next
Next
unlock pixels
if image exist(n) = 1 then delete image n
get image n,0,0,w,h,1 : delete bitmap n
bw = rnd(5)+5 : bh = rnd(5)+5 : bl = rnd(5)+5
if object exist(n) = 1 then delete object n
make object box n,bw*1.3,bh*1.3,bl*1.3
set object texture n,2,1
texture object n,n
scale object texture n,2,2
set object filter n,0
Endfunction
FUNCTION SCROLLSHOT(n,SX#,SY#)
SCROLL OBJECT TEXTURE n,SX#,SY#
Endfunction
FUNCTION DISTANCE(O1,O2)
OX1 = OBJECT POSITION X(O1) : OY1 = OBJECT POSITION Y(O1)
OX2 = OBJECT POSITION X(O2) : OY2 = OBJECT POSITION Y(O2)
A = ABS(OX2 - OX1) : B = ABS(OY2 - OY1)
C = (A^2) + (B^2) : C = CEIL(SQRT(C))
Endfunction C
function text_obj(n,t$,f$,size)
set text font f$
set text size size
w = text width(t$) : h = text height(t$)
create bitmap n,w,h
text 0,0,t$
if image exist(n) = 1 then delete image n
get image n,0,0,w,h,1 : delete bitmap n
if object exist(n) = 1 then delete object n
make object plane n,image width(n),image height(n)
texture object n,n
set object transparency n,1
set object light n,0
set object filter n,0
Endfunction
function preparegrid(n)
create bitmap n,101,101
cls 0
box 0,0,100,100,rgb(0,255,255) : box 1,1,99,99,rgb(0,0,0)
if image exist(n) = 1 then delete image n
get image n,0,0,100,100,1 : delete bitmap n
if object exist(n) = 1 then delete object n
make object plane n,4000,4000
texture object n,n
set object transparency n,1
set object filter n,0
set object light n,0
scale object texture n,400,400
set alpha mapping on n,50
position object n,0,0,10
Endfunction
function cloud_layer(n,w,h,c)
create bitmap n,w,h
cls 0
c1 = rgb(255,255,255)
for x = 0 to w-1
for y = 0 to h-1
if rnd(c) = 0 then dot x,y,c1
next
Next
if image exist(n) = 1 then delete image n
get image n,0,0,w,h,0 : delete bitmap n
make object plane n,160,90
set object transparency n,1
set object filter n,2
texture object n,n
scale object texture n,0.125,1
set object light n,1
endfunction
[size=+2]Forever and one[/size]