Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Project Sons of a Pixel - spaceship and weapons catalogue (chaoitic) sourcecode - but it WORKS!

Author
Message
Starshyne Emir
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 26th Apr 2018 09:15
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!



[size=+2]Forever and one[/size]
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th May 2018 09:59
Hi mate.
When I saw this line in my phone ...I couldn't figure out what you were referring to with " seed = wrap(seed+upkey()-downkey(),0,5000000000000000) " that are billions and billions . .
Very good effects really, especially those that are made with cones ... we could use lot of them for lasser effect .
The function to create textures is fine for endless walls, although the textures are somewhat small for other kind of walls like in my dungeon example. I will keep this for future 20 lines code

Cheers.
I'm not a grumpy grandpa
Starshyne Emir
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 11th May 2018 19:40
I use low-res for 2 reasons: 1) I am not a great programmer and simple graphics are easy to produce, and 2) this is the way I like to draw stuff hehehe.

Retro graphics like 1970's arcades mixed with 3D is what I want for my games. It is easier to draw and better for me to see on screen, 'cause I am almost completely blind - my sight is 1~3% or less and too many colours, shades, textures and effects are quite difficult for me to see correctly and notice eventual flaws on anything. Retro graphics are less detailed, I can notice if anything went wrong quickly - and I can code them easilty, too.

[size=+2]Forever and one[/size]
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th May 2018 20:41
Hi mate

If you come from 1970's you must be a grandpa like me. Retro games is what I like best...now I'm trying to make a raycasting kinda wolfentein in darkbasic pro...but is f...ing slow comparing with freebasic.

Now I understand why you prefer low resolution...never say die . I'm in the same boat myself somehow with my illness...and here am I.

That is truth that the forum has little activity an I have to spend my free time ...say reiventing the wheel looking here and there learning new easy lenguages.
I hope you all the best....good coding

Cheers
I'm not a grumpy grandpa
Starshyne Emir
7
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 11th May 2018 22:43
Not a grandpa, I'm 34. But I am pretty grumpy since I was a kid.

I grown up playing Atari, Mega Drive and SuperNES, and my first PC was a 486DX2 with mere 80Mhz of CPU and 24 megs of RAM - retrogaming is running deep through my veins. I started coding in QBASIC in 2006, after a night of booze - I came home, opened an old book about the history of computing and there was an algorithm written in BASIC in the last page and I said: "I can do that." And here I am.

Well, about raycasting, I can't be of much help. In DBPro there's the INTERCEPT OBJECT function that uses raycasting to detect if an object is intercepted by the ray. The only problem is: you need to know the number of the object you want to intercept BEFORE calling the function - it doesn't return which object was intercepted, it just check if a given object is intercepted or not. I never was able to make it work properly, I am terrible with collisions. In fact, my "bullets" in FPS were objects I needed to make fly from the "gun" straight forward, and when the bullet touched an enemy, then deleted the "bullet" and applied damage calculations to the enemy. It helps setting the bullet to camera orientation to ensure it will go forward or point it to the enemy directly to make a kind of "auto-aim". If you want to make something like this, opt for cubes that are relatively small and instance them to save some memory - or things will get slooooooooow...

Well, that's it.

If you want to chat, you can add me on FB, you can find me in www.facebook.com/emirstarshyne - I won't index the link 'cause I'm afraid it is not accepted by the forum's rules.


Well, now that's all.
[size=+2]Forever and one[/size]
gamehazer
5
Years of Service
User Offline
Joined: 2nd May 2018
Location:
Posted: 12th May 2018 01:13
This is giving me a error that says

global seed as double integer
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th May 2018 03:27
Chafari, I have been working on a Wolfenstein game in DBP also. I have no issues with game speed so far, but I have no idea how it would compare to FreeBasic.



So many games to code.....so little time.

Attachments

Login to view attachments
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th May 2018 10:52
Quote: "Not a grandpa, I'm 34."

I thought you could be older when you talk about 1070's ...you could be my son
The darkbasic intersect command is easy to understand and apply . Have a look to this piece of code



when we work in 2D, there are no intersect commands or rotate sprite or move sprite , but you have to create them yourself .
when we use INTERSECT command, with the purpose of detecting if we hit the enemy , once we detect that there really are no objects between the player and the enemy ... that means we can shoot the enemy ...we have to play with random checks to be able to hurt the enemy ...I mean
the way you like to do...
Quote: "if rnd(20)=1 and intersect= true then we can hurt the enemy"

Otherwise the enemy would die very fast ...the same thing would happen with the player .

About the facebook ....I'm an old man and I have never had such a thing nor wassap or whaever joung people say . . We can use the forum for our questions .

@LBFN
That really looks like Wolfenstein The most that I get to do, it was translate one of the freebasic codes into darkbasic but it was just 8 pfs.
The same code in Freebasic goes ok with more than 60 pfs . I went crazy to interpret Atan2
Quote: "pi=4 *atn(1)
twopi= 8* atn(1)
"

It is also crazy to know when to hide or show objects without the screen flickering annoyingly

As your picture say Gimme teh codez.... gimme teh minimum clue

Cheers.


I'm not a grumpy grandpa
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th May 2018 14:40
Chafari, I use Sparky's raycasting to check for collisions with the environment. I modeled the level myself and used as few polygons as possible (1284 faces, 3852 verts). The soldiers are actually more polies than the level. It runs about 45 FPS normally and does not appear to lag at that speed.

This code places my gun 'target' marker in place so I know where the shot will go.


When determining if I need to hide an object or not, I check it's distance from the camera using a vector. I have no issues at all with flickering.









So many games to code.....so little time.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th May 2018 16:48 Edited at: 16th May 2018 20:55
Quote: "Chafari, I use Sparky's raycasting to check for collisions with the environment."


Now I understand the misunderstanding . When I said above that I was trying to make an raycasting, I meant to make a raycasting engine like the one that use wolfenstein
Moving in a 3D space is so easy in Darkbasic Pro. We have nearly every thing to make a good game with good FPS. I can move a full speed in the example of dungeon I made two weeks ago o so.

When I saw your image at first I said to myself Holy moly !! what a resolution but then I realized that couldn`t be raycasting in such a quality.
Donkey's years there wasn't good PC with 3D graphic cards at all, so early 90's when wolfenstein was created, they made somthing like a fake 3D and invented the raycasting engine . You just need a 2D program like Qbasic to make your map that looks like a real 3D that we use in modern engines ...of course in low res 320*240 I think . Now most 2D lenguages are capable to make this engine even in flash for html. Darkbasic Pro is a modern lenguage that comes with 3D and we don't need it but just for the challenge of doing a raycasting engine with Darkbasic, we can not use any 3D object, we can not use MOVE or ROTATE or lot of commands that are only for 3D but we can use 2D and mathematics.
I don't know way Dbpro is so slow when even blitbasic purebasic and lot of 2D programming lenguages are much faster.

The final exe is less than 200kb yes!! less than 200kb ....purebasic can do it in just 50kb and the final result is as good as Dbpro in its hight resolution.

Here's a piece of code of freebasic :

Quote: "'$lang:"qb" 'RAY0-fb.BAS 'kinem
DIM L(7, 7):FOR Y = 0 TO 7: FOR X = 0 TO 7: READ L(X, Y): NEXT: NEXT
X = 1.5: Y = X: F = ATN(1): da = F / 9: SCREEN 13
2 fr = fr + 1: IF TIMER > tim THEN frr = fr: fr = 0: tim = TIMER + 1
FOR S = -160 TO 159: ss = ATN(S / 304): R = F + ss
if S=-50 then LOCATE 1, 1: PRINT frr
XI = COS(R) / 80: YI = SIN(R) / 80: X1 = X: Y1 = Y: nd = 0
DO: X1 = X1 + XI: Y1 = Y1 + YI: nd = nd + 1: c = L(X1, Y1): LOOP UNTIL c
Z=nd*COS(ss): H = 9000 / Z: xs = S + 160
LINE (xs, 0)-(xs, 99 - H), 0: LINE -(xs, 100 + H), c: LINE -(xs, 320), 8
NEXT: A$ = right$(INKEY$,1): F = F + da * ((A$ = "K") - (A$ = "M"))
xx = X + COS(F) / 16: yy = Y + SIN(F) / 16
IF A$ = "H" AND L(xx, yy) = 0 THEN X = xx: Y = yy
xx = X - COS(F) / 16: yy = Y - SIN(F) / 16
IF A$ = "P" AND L(xx, yy) = 0 THEN X = xx: Y = yy
IF A$ <> chr$(27) GOTO 2

DATA 1,1,5,1,1,1,1,1
DATA 1,0,0,1,0,0,0,11
DATA 1,0,0,4,0,2,0,111
DATA 3,0,0,0,0,1,0,11
DATA 1,0,1,1,0,4,0,8
DATA 1,0,1,1,0,1,0,9
DATA 1,0,0,0,0,0,0,1
DATA 1,2,3,4,5,6,7,1"

with just this code we can make a little map that will look like a real 3D....it only works in Freebasic, but I will add the exe to test..it is just 133kb

It is being like a pain in the neck trying to translate into Dbpro. It uses different math ... atan2 atn no correspont with atan or atanfull ....in most of thise programs, uses radiands instead of degrees and that is drivyng me crazy

Here the examples in purebasic and freebasic .Note my fkig antivirus sometimes tellme of wrong positives but I know that they are not...in case you have the the same problem.

Cheers

I'm not a grumpy grandpa

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-29 11:59:39
Your offset time is: 2024-03-29 11:59:39