* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Simple graphics in  (Read 1584 times)

0 Members and 1 Guest are viewing this topic.

Offline c4ooo

  • ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 877
  • Post Rating Ratio: +7/-2
  • ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    • View Profile
  • Gender: Male
Simple graphics in
« on: October 17, 2016, 11:44:25 pm »
So, recently some p2 has gotten into java. I have put together this code to help him figure out how to do stuff with the Java 2D api. This excample will display a magenta square that will follow your cursor.
(click to show/hide)
« Last Edit: October 18, 2016, 11:48:35 am by c4ooo »


??? ??? ???
C'est une signature

Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #1 on: October 18, 2016, 03:41:52 am »
Nice but not meaning to confuse young p2 - the key listener stuff..... and that big array of booleans
public static final boolean[] keyDown = new boolean[65536];

aren't really needed for the example. for simplicity's sake, you could take them out.

why so many bools in that array by the way??
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2030
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
    • View Profile
  • Gender: Male
Re: Simple graphics in
« Reply #2 on: October 18, 2016, 07:56:54 am »
Heey, just because I suck at Java it doesn't mean I'm a little kid  ;D

random internet quote: I swear it, it she ever says I'm too childish, she'll never get her nose back!


I guess every key got a number and it's a bool array to check for each key separately?
But that still qouldnt explain why there are that many bools in the array xD
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #3 on: October 18, 2016, 08:25:42 am »
Heey, just because I suck at Java it doesn't mean I'm a little kid  ;D

Well not many people see the value in having as bare-bones code as possible, ALWAYS, as a starting point. I swear by that (in most instances).

If you're not going to use that code (definitely not going to use) take it out. Or you might leave it in in this case.  ;)
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #4 on: October 18, 2016, 08:29:40 am »
Just found this list which looks more realistic.

(click to show/hide)

 (-_(//));
« Last Edit: October 18, 2016, 08:36:12 am by Snektron »
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3151
  • Post Rating Ratio: +31/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • View Profile
    • quantuminfinity
  • Gender: Male
Re: Simple graphics in
« Reply #5 on: October 18, 2016, 08:33:50 am »
I dont recommend using awt for anythkng serious. If you want to make a game in java you shoulf use either lwjgl (or jogl) directly or libGDX if you want helper functions. AWT is really slow.

Also: please post big chunks if code via a pastebin link, or put them in a
(click to show/hide)
tag.
« Last Edit: October 18, 2016, 08:35:29 am by Snektron »
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2030
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
    • View Profile
  • Gender: Male
Re: Simple graphics in
« Reply #6 on: October 18, 2016, 08:35:11 am »
yesss, a CODE tag please... O.o My mouse wheel is burning...  :ninja:
But anyways that list is interesting ^^
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #7 on: October 18, 2016, 08:37:06 am »
I dont recommend using awt for anythkng serious. If you want to make a game in java you shoulf use either lwjgl (or jogl) directly or libGDX if you want helper functions. AWT is really slow.
But for a 2D tilemap RPG game?
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3151
  • Post Rating Ratio: +31/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • View Profile
    • quantuminfinity
  • Gender: Male
Re: Simple graphics in
« Reply #8 on: October 18, 2016, 08:38:56 am »
Why not? libGDX not only supports 2D but also had an implementation for Tiled
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #9 on: October 18, 2016, 08:41:16 am »
Hey. Kill C4000 instead

(Sorry, thought you were attacking me  ;) ) lol
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline c4ooo

  • ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 877
  • Post Rating Ratio: +7/-2
  • ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    • View Profile
  • Gender: Male
Re: Simple graphics in
« Reply #10 on: October 18, 2016, 11:53:55 am »
Nice but not meaning to confuse young p2 - the key listener stuff..... and that big array of booleans
public static final boolean[] keyDown = new boolean[65536];

aren't really needed for the example. for simplicity's sake, you could take them out.

why so many bools in that array by the way??
Each value represents a key. You dont need every single key so its a bit overkill :P
The key constants are defined here: https://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html
So, in order to check if, for example, the "left arrow" key is down, do keyDown[KeyEvent.VK_LEFT];

yesss, a CODE tag please... O.o My mouse wheel is burning...  :ninja:
But anyways that list is interesting ^^
Either way you scroll either the page or the code box to read the code, so i guess a spoiler will do :P
??? ??? ???
C'est une signature

Offline Scipi

  • Full User
  • Domain Name Owner
  • CW 4x3 challenge - 3rd place
  • *
  • Join Date: Nov 2014
  • Location: Lost Town
  • Posts: 164
  • Post Rating Ratio: +1/-0
  • CodeKitten ^w^
    • s1ay3r44
    • Scipii
    • _Scipi
    • Scipi
    • View Profile
    • ScipiSoftware
  • Gender: Male
Re: Simple graphics in
« Reply #11 on: October 18, 2016, 05:10:05 pm »
I dont recommend using awt for anythkng serious. If you want to make a game in java you shoulf use either lwjgl (or jogl) directly or libGDX if you want helper functions. AWT is really slow.

I second this. Learning awt and such isn't useful if you're going to eventually just use an external library anyways. Also, taking a look at libGDX it gives you a lot of neat features. Tiled support is also a major plus.
  • Calculators owned: TI-83+, Nspire, Nspire CX, Casio Prizm




Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #12 on: October 18, 2016, 06:35:51 pm »
Nice but not meaning to confuse young p2 - the key listener stuff..... and that big array of booleans
public static final boolean[] keyDown = new boolean[65536];

aren't really needed for the example. for simplicity's sake, you could take them out.

why so many bools in that array by the way??
Each value represents a key. You dont need every single key so its a bit overkill :P
The key constants are defined here: https://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html
So, in order to check if, for example, the "left arrow" key is down, do keyDown[KeyEvent.VK_LEFT];

cool so it's like, virtual key codes. nice
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline kotu

  • Walrus Dehumidifier
  • Super User
  • Join Date: Aug 2016
  • Location: UK
  • Posts: 847
  • Post Rating Ratio: +6/-6
    • dj_kotu
    • @UCAy2ZF4hbc08iStnTn6jgxQ
    • rowanmedhurst
    • @djkotu
    • @romanov-psyco
    • View Profile
    • futurerave.uk
  • Gender: Male
Re: Simple graphics in
« Reply #13 on: October 19, 2016, 02:17:49 am »
Hey. Kill C4000 instead

LOOK

*kotu stabs C4000*
  • Calculators owned: TI 84+CE-T
  • Consoles, mobile devices and vintage computers owned: Sega Master System, Sony Playstation 3

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2030
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
    • View Profile
  • Gender: Male
Re: Simple graphics in
« Reply #14 on: October 19, 2016, 09:13:00 am »
heey, no wars here pls @kotu @c4ooo just eat another cookie and relax, ok? :)
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games