Author |
Topic: Sub-processes (Read 431 times) |
|
Usama Amin
New Member
member is offline


Gender: 
Posts: 18
|
 |
Sub-processes
« Thread started on: Dec 1st, 2012, 3:44pm » |
|
Hi, I am currently working on a 2d sidescrolling shooter. Does anyone know a way so that i can still make my character move around and at the same time, fire a projectile? Also im a newbie coder can someone upload example code of a bullet being fired to the right of the screen until it is out of view then another can be fired? Thanks Usama
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Sub-processes
« Reply #1 on: Dec 1st, 2012, 9:53pm » |
|
on Dec 1st, 2012, 3:44pm, Usama Amin wrote:can someone upload example code of a bullet being fired to the right of the screen until it is out of view then another can be fired? |
|
The very simple program below illustrates a common way of achieving that. Use the cursor keys to move the 'gun', and the space bar to fire:
Code: MODE 9
ORIGIN 0,512
GCOL 128+4
CLG
VDU 23,128,&C0,&F0,&FC,&FF,&FF,&FC,&F0,&C0
GunX% = 0
GunY% = 0
BulletX% = 1280
BulletY% = 0
VDU 5
REPEAT
GCOL 3,9
MOVE GunX%, GunY% : VDU 128
GCOL 3,11
PLOT BulletX%, BulletY%
WAIT 2
GCOL 3,9
MOVE GunX%, GunY% : VDU 128
GCOL 3,11
PLOT BulletX%, BulletY%
CASE INKEY(0) OF
WHEN 32:
IF BulletX% >= 1280 THEN
BulletX% = GunX% + 32
BulletY% = GunY% - 16
ENDIF
WHEN 136: GunX% -= 4
WHEN 137: GunX% += 4
WHEN 138: GunY% -= 4
WHEN 139: GunY% += 4
ENDCASE
IF BulletX% < 1280 BulletX% += 8
UNTIL FALSE For some more sophisticated examples you can look in the Games folder on the Yahoo group and on the BB4WGAMES web site:
http://tech.groups.yahoo.com/group/bb4w/files/Games/ http://bb4wgames.com/
Richard.
|
|
Logged
|
|
|
|
Usama Amin
New Member
member is offline


Gender: 
Posts: 18
|
 |
Re: Sub-processes
« Reply #2 on: Dec 1st, 2012, 10:05pm » |
|
Thank You!
|
|
Logged
|
|
|
|
David Williams
Developer
member is offline

meh

Gender: 
Posts: 452
|
 |
Re: Sub-processes
« Reply #3 on: Dec 4th, 2012, 5:54pm » |
|
The GFXLIB package comes with a little mini-game called 'Cowboy' which happens to be all about shooting bullets!
Take a look at the code, it might give you some useful ideas.
Regards,
David.
|
|
Logged
|
|
|
|
Usama Amin
New Member
member is offline


Gender: 
Posts: 18
|
 |
Re: Sub-processes
« Reply #4 on: Dec 4th, 2012, 7:12pm » |
|
Yes, i have seen it and implemented it in my game
|
|
Logged
|
|
|
|
|