Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

shrink code

This topic is 2464 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there anyway to condense this code


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage1 = [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]@"c:\Users\phil\Desktop\brick1.bmp"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage1, 0, 0);[/font][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage2 = [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]@"c:\Users\phil\Desktop\brick1.bmp"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage2, 150, 0);[/font][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage3 = [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]@"c:\Users\phil\Desktop\brick1.bmp"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage3, 300, 0);[/font][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage4 = [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]@"c:\Users\phil\Desktop\brick1.bmp"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage4, 450, 0);[/font][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage5 = [/font][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]@"c:\Users\phil\Desktop\brick1.bmp"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/font][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage5, 600, 0);[/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
why are you loading the same image 5 times and then drawing it in 5 different positions. Load it once. Draw it five times.

Also, for loop, read up on it.

Share this post


Link to post
Share on other sites
thanks washu, that helped,do you know of anywhere I can get help with collision detection and breakout game and c#

Share this post


Link to post
Share on other sites
Coldet depends, but since you're using 2d... I would probably look at something like box2d. Its a 2d physics engine and has C# ports out there (google em). That includes collision and collision response.

Share this post


Link to post
Share on other sites
Yes, you should. Its pretty simple (in 2d) but its a nice thing to know and understand. You should read up and understand both OOBB (object oriented bounding boxes) and AABB (axis aligned bounding boxes) and how to perform coldet on them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!