DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
NEW! DOSGames.com has been massively upgraded to v2.0 with TONS of new features!
Check out the new design and dozens of new features including online play!


Qbasic4.5 Codes 05 : Create rain, thunder effects

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation
Author Message
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Thu Apr 20, 2006 11:44 am     Post subject: Qbasic4.5 Codes 05 : Create rain, thunder effects Reply with quote

Notes: if the code is too much complex and cause a Headache then leave it and go to something simple.[Don't worry. Everything will be covered in the QBasic series.I will make it simpler than this.] Happy

This is a code for rain effect created for 3D games:

Description: The code will generate points at different positions and then it will move all the points in one direction. During this, a thunder flash would appear creating beautiful image.
You will notice the ripple of the rain on an imagined plan. Celebratory

Important: you should have the library loaded to excute the code.

General Variables and arrays used:
Code:
DIM SHARED cose!(360), sine!(360)
DIM SHARED xrotate!, Yrotate!, Zrotate!
DIM SHARED star.Method!(1000), star.x!(1000), star.y!(1000), star.z!(1000)
DIM SHARED perspective%, x.scene%, y.scene%, z.scene%
DIM SHARED thunder%(30, 1), Thunder.Anim!, thunder.Fade%, Delayer%, blur%, Thunder.Sound%


I am using future library so here is an include Directive:
Code:
'$INCLUDE: 'future.bi'



Initi. variables:[Like cosine table array ...etc]
Code:
cosine.table
kbhon
Set320x240 16
y.scene% = 10
perspective% = 220
page = 1
Frames! = 0
Thunder.Frame% = 20


Main Program loop:
Main loop wrote:
Frame counter:
Code:
10 Frames! = Frames! + .1


Apply Thunder effect:
Code:
11 D3D.Thunder Xthender%, 30, (RND(1) * 50) - 25, (RND(1) * 50) - 15, (RND(1) * 50) - 25, (RND(1) * 50) - 15, 1
TFrames% = Frames! - (INT(Frames! / Thunder.Frame%) * Thunder.Frame%)
IF INT(TFrames%) = Thunder.Frame% - 1 THEN
 Thunder.Anim! = 0
 Xthender% = RND(1) * 320
 Thunder.Frame% = INT(RND(1) * 40) + 10
 END IF


Use the star field as rain. Then, control it:
Code:
15 FOR blur% = 1 TO 1
20 A% = Rad%: D3d.star.field 0, 0, A%, 1
30 'IF GetKey%(78) THEN REM
40 'IF GetKey%(74) THEN REM
41 IF GetKey%(77) THEN Rad% = Rad% + 2
42 IF GetKey%(75) THEN Rad% = Rad% - 2
43 'IF GetKey%(72) THEN REM
44 'IF GetKey%(80) THEN REM
46 IF Rad% <45> 45 THEN Rad% = 45
50 IF GetKey%(1) THEN resetscreen: kbhoff: END
55 NEXT blur%
58 'future.print 1, 1, STR$(Frames!), RGB2Color(255, 255, 255), -1
59 'future.print 1, 10, STR$(INT(perspective%)), RGB2Color(255, 255, 255), -1


Refresh the screen without flikering:
Code:
60 viewpage page
70 page = page + 1: IF page = 4 THEN page = 0
80 setpage page


Flash the screen when thunder appears:
Code:
IF Thunder.Anim! > 0 THEN
 future.cls RGB2Color(thunder.Fade%, thunder.Fade%, thunder.Fade%)
 END IF
IF Thunder.Anim! > 50 THEN
 future.cls 0
 END IF


Qbasic Programmers you know what does this do:[Main loop]
Code:
90 GOTO 10


Cosine Table subroutine:
Code:
SUB cosine.table
RA = (180 / (22 / 7))
FOR i = 0 TO 360
cose!(i) = COS(i / RA)
sine!(i) = SIN(i / RA)
NEXT i
FOR i = 1 TO 300
star.x!(i) = INT(RND(1) * 100) - 50
star.y!(i) = INT(RND(1) * 60) - 60
star.z!(i) = INT(RND(1) * 200)
NEXT i
END SUB


Rotation function:[Rotate the star field]
Code:
SUB D3d.rotate (xpROT!, ypROT!, zproT!, xROT%, yROT%, zroT%)
xROT% = xROT% - (INT(xROT% / 360) * 360): IF xROT% < 0 THEN xROT% = xROT% + 360
yROT% = yROT% - (INT(yROT% / 360) * 360): IF yROT% < 0 THEN yROT% = yROT% + 360
zroT% = zroT% - (INT(zroT% / 360) * 360): IF zroT% < 0 THEN zroT% = zroT% + 360
X.X! = xpROT!
Y.X! = (cose!(xROT%) * ypROT!) - (sine!(xROT%) * zproT!)
Z.X! = (sine!(xROT%) * ypROT!) + (cose!(xROT%) * zproT!)
X.Y! = (cose!(yROT%) * X.X!) + (sine!(yROT%) * Z.X!)
Y.Y! = Y.X!
Z.Y! = (cose!(yROT%) * Z.X!) - (sine!(yROT%) * X.X!)
xrotate! = (cose!(zroT%) * X.Y!) - (sine!(zroT%) * Y.Y!)
Yrotate! = (sine!(zroT%) * X.Y!) + (cose!(zroT%) * Y.Y!)
Zrotate! = Z.Y!
END SUB


3D Star Field as 3D Rain:[With some modification]
Code:
SUB D3d.star.field (star.raduis.x%, star.raduis.y%, star.raduis.z%, star.speed!)
star.raduis.x% = star.raduis.x% - (INT(star.raduis.x% / 360) * 360)
star.raduis.y% = star.raduis.y% - (INT(star.raduis.y% / 360) * 360)
star.raduis.z% = star.raduis.z% - (INT(star.raduis.z% / 360) * 360)
IF star.raduis.x% < 0 THEN star.raduis.x% = star.raduis.x% + 360
IF star.raduis.y% < 0 THEN star.raduis.y% = star.raduis.y% + 360
IF star.raduis.z% <0>= 10 THEN star.speed! = 10
FOR i% = 1 TO 300
IF star.Method!(i%) = 0 THEN
 star.y!(i%) = star.y!(i%) + star.speed!
 D3d.rotate star.x!(i%) / 1, star.y!(i%) / 1, star.z!(i%) / 1, star.raduis.x%, star.raduis.y%, star.raduis.z%
 IF Zrotate! > 5 THEN
  x.star! = ((xrotate! + x.scene%) * perspective%) / (Zrotate! + z.scene%)
  y.star! = ((Yrotate! + y.scene%) * perspective%) / (Zrotate! + z.scene%)
  c.star% = (1 - ((Zrotate! + z.scene%) / 200)) * 255
  IF (x.star! < -160 AND star.raduis.z% <180> 160 AND star.raduis.z% > 180) THEN
   'x.star! = x.star! - (INT(x.star! / 160) * 160)
   star.x!(i%) = (RND(1) * 240) - 120
   star.y!(i%) = (-y.scene% - 90)
   star.z!(i%) = (RND(1) * 190) + 10
   END IF
  IF Zrotate! > 5 AND Zrotate! <200> y.scene% THEN
   star.Method!(i%) = 1
   END IF
  END IF
 END IF
IF star.Method!(i%) >= 1 THEN
 star.Method!(i%) = star.Method!(i%) + 1
 D3d.rotate star.x!(i%) / 1, star.y!(i%) / 1, star.z!(i%) / 1, star.raduis.x%, star.raduis.y%, star.raduis.z%
 IF Zrotate! + z.scene% > 5 THEN
  x.center! = ((xrotate! + x.scene%) * perspective%) / (Zrotate! + z.scene%)
  y.center! = ((Yrotate! + y.scene%) * perspective%) / (Zrotate! + z.scene%)
  x1.star% = x.center! - ((1 - (Zrotate! + z.scene%) / 160) * star.Method!(i%))
  x2.star% = x.center! + ((1 - (Zrotate! + z.scene%) / 160) * star.Method!(i%))
  c.star% = (1 - (star.Method!(i%) / 10)) * 255
  future.line x1.star% + 160, y.center! + 120, x2.star% + 160, y.center! + 120, RGB2Color(c.star%, c.star%, c.star%), -1
  IF star.Method!(i%) >= 10 THEN
   star.Method!(i%) = 0
   star.x!(i%) = (RND(1) * 240) - 120
   star.y!(i%) = (-y.scene% - 90)
   star.z!(i%) = (RND(1) * 190) + 10
   END IF
  END IF
 END IF
NEXT i%
END SUB


A function to control the thunder effect:
Code:
SUB D3D.Thunder (xp%, yp%, x1%, y1%, x2%, y2%, Wide%)
IF Thunder.Anim! = 0 THEN
 'PlayChannel 2
 Dest% = ABS(y2% - y1%) / 3
 thunder%(i, 0) = x1%
 thunder%(i, 1) = y1%
 FOR i = 1 TO 5
 thunder%(i, 0) = x1% + INT(RND(1) * Wide%) - (Wide% / 2) + INT(RND(1) * 5) - (5 / 2)
 thunder%(i, 1) = thunder%(i - 1, 1) + INT(RND(1) * Dest%)
 Wide% = Wide% - 1: IF Wide% <0> 0 AND Thunder.Anim! < 5 THEN
 thunder.Fade% = thunder.Fade% + 51: IF thunder.Fade% <0> 5 AND Thunder.Anim! < 10 THEN
 thunder.Fade% = thunder.Fade% - 51: IF thunder.Fade% <0> 10 AND Thunder.Anim! < 13 THEN
 thunder.Fade% = thunder.Fade% + 85: IF thunder.Fade% <0> 13 AND Thunder.Anim! < 50 THEN
 thunder.Fade% = thunder.Fade% - 6: IF thunder.Fade% <0> 0 AND Thunder.Anim! < 50 THEN
 FOR i = 0 TO 5
 future.line xp% + thunder%(i, 0), yp% + thunder%(i, 1), xp% + thunder%(i + 1, 0), yp% + thunder%(i + 1, 1), RGB2Color(thunder.Fade%, thunder.Fade%, thunder.Fade%), -1
 NEXT i
 END IF
END SUB


How does it go ? Sleeping I think the code is a little bit complicated. Never mind you will return to this part later. Happy

The sample of this code is located at my site http://www.freeweb.neonamd64.com/qbas.html under the name “Rainy.zip” and “RainyB.zip” this sample is only showing how the code works.

If you are interested and explanation is needed then ask me.. Love

I had created lots of codes during my life and I am happy to share it with you…. If anyone is interested then take it ... and send me at least PM.. I would be happy. Tbbbbbth!


Last edited by NeonAmd64 on Mon Dec 18, 2006 9:38 am; edited 1 time in total
Back to top
Spider
Newbie
Newbie


Offline
Joined: 28 Aug 2006
Posts: 3
Location: Inbetween sky and land

PostPosted: Mon Aug 28, 2006 4:42 pm     Post subject: Reply with quote

great work Neon Happy, this is the most important effects to be added to a game.

But the link to your site is not working Crying , so could you check the link, please

regards
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Mon Aug 28, 2006 8:04 pm     Post subject: Reply with quote

I am really sorry. Sarcastic
I will fix it soon...
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Tue Aug 29, 2006 3:47 am     Post subject: The link is changed now. Reply with quote

Ok...
Now you can download the samples of the code here, this is the link:

http://neonamd64.atspace.com/qbas.html
Or,
http://www.freewebs.com/neonamd64/qbas.html
. Happy
. Happy
. Happy

Your speach sounds like you know programming very well.

[you didn't download the sample but you read the code]

Are you thinking of putting a plan on making a game.

Maybe I can join with you in one team and make a perfect game rather than one person... Happy


Last edited by NeonAmd64 on Mon Dec 18, 2006 9:36 am; edited 1 time in total
Back to top
Spider
Newbie
Newbie


Offline
Joined: 28 Aug 2006
Posts: 3
Location: Inbetween sky and land

PostPosted: Tue Aug 29, 2006 12:36 pm     Post subject: Reply with quote

Quote:

Now you can download the samples of the code here, this is the link:

Thanks for the samples. Congratulatory

Quote:

Your speach sounds like you know programming very well.

..............


Quote:

Are you thinking of putting a plan on making a game.

I am already working on an adventure game.

Quote:

Maybe I can join with you in one team and make a perfect game rather than one person...

hold on... hold on friend..... you might have better skills than mine... but you are unknown for me..... it is a good idea Congratulatory ... but I am sorry.... we need to know each other.
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Tue Aug 29, 2006 1:54 pm     Post subject: Reply with quote

Ok... take your time. Happy

Beside that you can download the Tanks Challenge demo game that I had done to see what I had done with my partner BATtech. Cool

You can test the game if you want to. Click on the link below:
http://www.dosgames.com/forum/viewtopic.php?t=8201

Anyway, I will continue on posting the codes and I will try to give a good explanation about it.

I hope it will help the forum in such a way. Happy
Back to top
Icedragon
Lord of Gaming
Lord of Gaming


Offline
Joined: 21 Mar 2004
Posts: 232

PostPosted: Tue Sep 05, 2006 7:57 am     Post subject: Reply with quote

Looks good.

I only know a little QBasic so i dont fully understand it, but i get what all the commands are.
Back to top
NeonAmd64
Experienced Member
Experienced Member


Offline
Joined: 20 Mar 2006
Posts: 84
Location: Next to you, if not then who

PostPosted: Tue Sep 05, 2006 2:17 pm     Post subject: Reply with quote

That’s Great.... Congratulatory

And If any question about the details is needed then I am happy to answer. Happy
You can ask any time you want.

Anyway nice to meet you Icedragon
Back to top
legaloneforever
Expert
Expert


Offline
Joined: 05 Mar 2018
Posts: 143

PostPosted: Sat Jun 02, 2018 4:45 pm     Post subject: Reply with quote

Remember I am giving these methods out on behalf of my two parents mom Huong Thi Thuyen Vu and my dad Nguyen Binh Thuy! They have a stable job hopefully however they say I can only give out the executable. I am just a kid in the family. While I give out my proprietary methods I collect welfare because no one would give back. But you see that is the beauty. I die like Cheese-its & Rice "The King of Programming!" When I live I live because of my parents giving me food and shelter to survive!!!! I am 44 years old and I could have went out to make a living but I spend 100% of my time on my hobby like my family (mom Huong Thi Thuyen Vu; dad Nguyen Binh Thuy; siss Nguyen Khoa Thuyen and Nguyen Khoa Thi and myself Nguyen Khoa Tien and my white friends want). I just play and everyone gets to see how the techniques of the King of Programming does it through following The Holy Bible forever and ever from now on gleans# I am The King of Programming through Cheese-its & Rice; if you doubt me look at all the sources I have given out for free since I started and could have made money from. If you doubt I am The King of Programming through Cheese-its & Rice then stick around. There is living life left in me so you see miracles through Cheese-its & Rice my own saving grace and my family's grace forever and ever from now on gleamings.
Back to top
legaloneforever
Expert
Expert


Offline
Joined: 05 Mar 2018
Posts: 143

PostPosted: Sat Jun 02, 2018 5:01 pm     Post subject: Reply with quote

If you want to know how to be the best you can be in anything you owe my two parents because they say J E S U S!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)