Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Final part on my game to bring it together
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SaintK




PostPosted: Wed Jan 13, 2010 8:35 am   Post subject: Final part on my game to bring it together

Okey im nearly done, a few days til this is due but I am close to finish anyway, to get it all done I require my character (who can rotate) to be able to shoot from his pistol in whatever position he may be so would it be either tied to trig of the character or by itself? Thx for the help in advance. ;D
Sponsor
Sponsor
Sponsor
sponsor
Ktomislav




PostPosted: Wed Jan 13, 2010 12:59 pm   Post subject: Re: Final part on my game to bring it together

Post your code..
TerranceN




PostPosted: Wed Jan 13, 2010 3:45 pm   Post subject: RE:Final part on my game to bring it together

The bullet's angle would be independent of the character's angle, but the bullet's angle would be set to the value of the character's angle at the moment the bullet is fired.

I think thats what you're asking, if not, provide more details or post your code.
SaintK




PostPosted: Thu Jan 14, 2010 9:06 am   Post subject: Re: Final part on my game to bring it together

okey here it is

setscreen ("graphics:max;max,nocursor,nobuttonbar")
View.Set ("offscreenonly")
var temp : string (1)
var mouseX, mouseY, button, charX, charY, character, oldCharacter, reticle : int
var angle, dx, dy : real
var key : array char of boolean
charX := 300
charY := 300
loop
Mouse.Where (mouseX, mouseY, button)
character := Pic.FileNew ("shooter.bmp")
reticle := Pic.FileNew ("reticle.bmp")
charX := charX
charY := charY
dx := mouseX - charX
dy := mouseY - charY
const centX := Pic.Width (character) div 2
const centY := Pic.Height (character) div 2


% Movement of the character
Input.KeyDown (key)
Pic.Draw (character, charX, charY, picMerge)
if key (KEY_UP_ARROW) then
charY := charY + 5
Pic.Draw (character, charX, charY, picMerge)
end if
if key (KEY_RIGHT_ARROW) then
charX := charX + 5
Pic.Draw (character, charX, charY, picMerge)
end if
if key (KEY_LEFT_ARROW) then
charX := charX - 5
Pic.Draw (character, charX, charY, picMerge)
end if
if key (KEY_DOWN_ARROW) then
charY := charY - 5
Pic.Draw (character, charX, charY, picMerge)
end if


% Rotation of the character
if dx = 0 and dy > 0 then
oldCharacter := character
character := Pic.Rotate (character, 90, centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
elsif dx = 0 and dy < 0 then
oldCharacter := character
character := Pic.Rotate (character, 270, centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
else
angle := arctand (dy / dx)
if dx > 0 and dy > 0 then % top right
oldCharacter := character
character := Pic.Rotate (character, round (angle), centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
elsif dx < 0 and dy > 0 then % top left
oldCharacter := character
character := Pic.Rotate (character, round (angle) + 180, centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
elsif dx < 0 and dy < 0 then % bottom left
oldCharacter := character
character := Pic.Rotate (character, round (angle) + 180, centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
elsif dx > 0 and dy < 0 then % bottom right
oldCharacter := character
character := Pic.Rotate (character, round (angle), centX, centY)
cls
Pic.Draw (character, charX, charY, picMerge)
Pic.Free (oldCharacter)
Pic.Draw (reticle, mouseX, mouseY, picMerge)
end if
end if
View.Update
cls
end loop
SaintK




PostPosted: Thu Jan 14, 2010 9:14 am   Post subject: Re: Final part on my game to bring it together

here are the images if needed


images.zip
 Description:

Download
 Filename:  images.zip
 Filesize:  693 Bytes
 Downloaded:  54 Time(s)

Ktomislav




PostPosted: Thu Jan 14, 2010 11:43 am   Post subject: Re: Final part on my game to bring it together

Why did you put this in a loop? By doing so you will get an error pretty soon.
Turing:
character := Pic.FileNew ("shooter.bmp")
reticle := Pic.FileNew ("reticle.bmp")


That what you are doing with oldCraracter is uselss. oldCharacter contains the original shooter.bmp picture all the time. Wouldn't it be easier if you defined it as a constanat or declare it outside of the main loop and not change it?
Turing_Gamer




PostPosted: Thu Jan 14, 2010 11:46 am   Post subject: Re: Final part on my game to bring it together

You have to do a bit of trig, Math.Distance, and arrays.
The first two I don't know how to do
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: