• Advertisement
Sign in to follow this  

shrink code

This topic is 2131 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[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage1 = [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/size][/font][/size][/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"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage1, 0, 0);[/size][/font][/size][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage2 = [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/size][/font][/size][/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"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage2, 150, 0);[/size][/font][/size][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage3 = [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/size][/font][/size][/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"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage3, 300, 0);[/size][/font][/size][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage4 = [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/size][/font][/size][/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"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage4, 450, 0);[/size][/font][/size][/font]


[font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] curImage5 = [/size][/font][/size][/font][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"][font="Consolas"][size="2"][color="#2b91af"]Image[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"].FromFile([/size][/font][/size][/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"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]g.DrawImage(curImage5, 600, 0);[/size][/font][/size][/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
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