Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Preformance With DrawImage!  (Read 1530 times)
0 Members and 1 Guest are viewing this topic.
Offline VIrtueeL
« Posted 2014-12-14 11:15:25 »

ok am drawing this on my screen // this is backround for the 2d platformer btw


but i don't want to draw it all i only want to draw what the screen can see

for example here i want to only draw whats inside that red rectangle


i got it working with tiles and stuff using a collision box but i have never done it with an full image

do i need to get the pixels that are colliding and so how do i do that?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline matanui159

JGO Coder


Medals: 11
Projects: 1
Exp: 10-12 months


Aww... So cute...


« Reply #1 - Posted 2014-12-14 11:17:59 »

What are u using?
OpenGL: change the texture coords
Java2D: Graphics.setClip(x, y, width, height)
Thats all that I know

hope this helps! Cheesy

Is it sad that I still get a fright when the computer beeps at me...
Offline VIrtueeL
« Reply #2 - Posted 2014-12-14 11:31:30 »

Thanks so much! this is gonna make everything so much easier

so does it still load the pixels outside the clip?

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lcass
« Reply #3 - Posted 2014-12-14 11:41:18 »

I would guess so , its a clip function not a modified load function , if you are going to do something like this take a look at buffered rendering.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #4 - Posted 2014-12-14 16:58:05 »

If you really care about performance move onto some framework that uses opengl.

But that does not really answer your question.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #5 - Posted 2014-12-14 21:50:19 »

Why use setClip when the drawImage method does it for you?

drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)


Offline VIrtueeL
« Reply #6 - Posted 2014-12-15 08:57:12 »

would you mind giving those varibles names, first time am doing this.. with and image!

i do devlogs and i do tutorials check em out
https://www.youtube.com/user/InidDevo
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #7 - Posted 2014-12-15 15:14:38 »

http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20java.awt.image.ImageObserver)
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1577 views)
2018-06-10 19:43:48

EgonOlsen (1661 views)
2018-06-10 19:43:44

EgonOlsen (1146 views)
2018-06-10 19:43:20

DesertCoockie (1575 views)
2018-05-13 18:23:11

nelsongames (1175 views)
2018-04-24 18:15:36

nelsongames (1666 views)
2018-04-24 18:14:32

ivj94 (2422 views)
2018-03-24 14:47:39

ivj94 (1632 views)
2018-03-24 14:46:31

ivj94 (2722 views)
2018-03-24 14:43:53

Solater (886 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!