* 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: Walrus Kingdom (former PocketWalrus)  (Read 14466 times)

0 Members and 1 Guest are viewing this topic.

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18435
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #240 on: April 11, 2017, 10:32:24 pm »
Good luck. I hope this doesn't kill the project or require a full rewrite again o.o

Little dinosaur walrii at the bottom of the screen would be sad D:
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2259
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #241 on: April 11, 2017, 11:11:40 pm »
nah it just means that all plans to maybe rewrite parts of the code aren't possible. So I'll stick with my current engine.
Still I have to add lots of map data, new tiles and add all of the story line stuff >.<
I even have to add NPCs first, they don't exist yet <--- major code change

Edit:
*which is hard spending almost all the time on pxls.space x.x
So I won't have tome to work on it atm :/
  • 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)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18435
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #242 on: April 12, 2017, 04:28:35 am »
Yeah I hoped you won't spend all your time on pxl.space especially since it's gonna be reset at one point or another. Wod suck to lose you in the same style we lost active members to Freecodecamp D: @p2 (eg alexgt)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2259
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #243 on: April 15, 2017, 06:52:42 am »
Nah don't worry u got me addicted to this site a long time ago <3 no way I'm gonna leave ^^
Guess as soon as I find the time, I'll take my first approach on adding smooth scrolling x.x
Just hope I do t break everything xD

Buuut then I'll have to handle the line of tiles touching the border completely different which requires major changes to the rendering thingy... so I guess that might take some time ^^
  • 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)

Online xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18435
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #244 on: April 15, 2017, 08:38:21 pm »
Yeah for smooth scrolling you need to draw an extra row and column and maybe you need two extra variables
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline c4ooo

  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 947
  • Post Rating Ratio: +10/-2
  • Advanced forumer
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #245 on: April 15, 2017, 08:42:29 pm »
Store x and y position in pixels. Then, loop through each tile, and render each tile at (tileX * tileSize -playerX + (windowWidth / 2), tileY * tileSize - playerY + (windowHeight / 2)). Once you do that, it shouldn't be hard to use two nested for loops to only render the tiles around the player.
« Last Edit: April 15, 2017, 08:47:19 pm by c4ooo »

Offline p2

  • CodeWalrus Staff
  • Super User
  • Moderator
  • CodeWalrus Supporter
  • *
  • Join Date: Aug 2016
  • Location: Germany
  • Posts: 2259
  • Post Rating Ratio: +8/-0
  • *Wubba lubba dub dub*
    • KaliPhobos
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #246 on: April 16, 2017, 02:07:15 pm »
It's a bit more complicated:

Forst I calculate the top-left position of the screen in the map:
Code: [Select]
screenTop = General.getBetween(0, Map.getHeight()-getHeight(), Player.getYPos()-Math.round(getHeight()/2));
screenLeft = General.getBetween(0, Map.getWidth()-getWidth(), Player.getXPos()-Math.round(getWidth()/2));
// getWidth() returns the width of the screen in tiles
// Map.getWidth() returns the map dimensions

I do this to get the currently relevant map data, which is then copied to a second matrix: ScreenMatrix[_x][_y]
It basically is a screen-sized region of the map centered around the walrus, but one that cannot leave the map (so the walrii is only centered if it isn't too close to the edge).

starting from this point, I have the following methods (sorry for bad readability):
Code: [Select]
public static void renderBackground(boolean ForceUpdate) {
// Renders background layer *obviously*
for(int _y=0;_y<getHeight();_y++) {
for(int _x=0;_x<getWidth();_x++) {
double data = ScreenMatrix[_x][_y]; // load raw data
double dataOld = ScreenMatrixOld[_x][_y];
if (data!=dataOld | ForceUpdate == true) { // Player moved
int _background = Map.getBackgroundID(data); // extract background data
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(_background), TileSource.getYPos(_background), window.blocksize*_x, window.blocksize*_y); // render background layer
} else { // To prevent area around the character to be rendered twice (messes up partially transparent tiles in the menu plus slows down)
if (General.isCloseToChar(_x, _y)) { // prevent shadows when close to the edge on in ScrollLock regions
int _background = Map.getBackgroundID(data); // extract background data
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(_background), TileSource.getYPos(_background), window.blocksize*_x, window.blocksize*_y); // render background layer
}
}
}
}
}
public static void renderForeground(boolean ForceUpdate) {
// Renders foreground layer *obviously*
for(int _y=0;_y<getHeight();_y++) {
for(int _x=0;_x<getWidth();_x++) {
double data = ScreenMatrix[_x][_y]; // load raw data
double dataOld = ScreenMatrixOld[_x][_y];
if (data!=dataOld | ForceUpdate == true) { // Update to map data or player moved
int _foreground = Map.getForegroundID(data); // extrace foreground data
if(_foreground>0 && General.isCloseToChar(_x, _y)==false) { // To prevent area around the character to be rendered twice (messes up partially transparent tiles in the menu plus slows down)
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(_foreground), TileSource.getYPos(_foreground), window.blocksize*_x, window.blocksize*_y);
}
}
if (General.isCloseToChar(_x, _y)) { // prevent shadows when close to the edge on in ScrollLock regions
int _foreground = Map.getForegroundID(data); // extrace foreground data
if(_foreground>0) {
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(Map.getForegroundID(data)), TileSource.getYPos(Map.getForegroundID(data)), window.blocksize*_x, window.blocksize*_y);
}
}
}
}
}
public static void renderWalrus() {
for(int _y=0;_y<getHeight();_y++) {
for(int _x=0;_x<getWidth();_x++) {
if (scrollLocked==false) {
if(General.getBetween(0, Player.getXPos()-Math.round(getWidth()/2), Map.getWidth()-getWidth())+_x == Player.getXPos() && General.getBetween(0, Player.getYPos()-Math.round(getHeight()/2), Map.getHeight()-getHeight())+_y == Player.getYPos()) {
int _background = Map.getBackgroundID(ScreenMatrix[_x][_y]); // extract background data
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(_background), TileSource.getYPos(_background), window.blocksize*_x, window.blocksize*_y); // render background layer
PlayerTile = Player.getCurrentTile()+Player.TileChangeWhileWalking;
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(PlayerTile), TileSource.getYPos(PlayerTile), window.blocksize*_x, General.getMax(window.blocksize*_y-window.blocksize/4, 0)); // render char
Player.newLastXPos = _x;
Player.newLastYPos = _y;
int _foreground = Map.getForegroundID(ScreenMatrix[_x][_y]); // extrace foreground data
if(_foreground>0) {TileArea.drawTile(tiles, TileSource.getXPos(_foreground), TileSource.getYPos(_foreground), window.blocksize*_x, window.blocksize*_y);} // add foreground layer

}
} else { //This disables the automated screenscrolling for special areas on the map (like in huge gardens) so only the y-axis scrolls. Similar to behavior close to map's edges
if(Player.getXPos()-screenLeft==_x && General.getBetween(0, Player.getYPos()-Math.round(getHeight()/2), Map.getHeight()-getHeight())+_y == Player.getYPos()) {
int _background = Map.getBackgroundID(ScreenMatrix[_x][_y]); // extract background data
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(_background), TileSource.getYPos(_background), window.blocksize*_x, window.blocksize*_y);
PlayerTile = Player.getCurrentTile()+Player.TileChangeWhileWalking;
TilesDrawn++;
TileArea.drawTile(tiles, TileSource.getXPos(PlayerTile), TileSource.getYPos(PlayerTile), window.blocksize*_x, General.getMax(window.blocksize*_y-Math.round(getZoom()/4), 0)); // render char
Player.newLastXPos = _x;
Player.newLastYPos = _y;
int _foreground = Map.getForegroundID(ScreenMatrix[_x][_y]); // extrace foreground data
if(_foreground>0) {TileArea.drawTile(tiles, TileSource.getXPos(_foreground), TileSource.getYPos(_foreground), window.blocksize*_x, window.blocksize*_y);} // add foreground layer
}
}
}
}
}
public static void render(boolean ForceUpdate) {
// main class that does all the rendering
renderBackground(ForceUpdate);
renderWalrus();
renderForeground(ForceUpdate);
Trigger.trigger(Player.getXPos(), Player.getYPos());
if(Trigger.get(Player.getXPos(), Player.getYPos())==0.0 && forceUpdateNextTime==true) { // To prevent left over fragments from popups
forceUpdateNextTime = false;
render(true);
}
Player.lastXPos = Player.newLastXPos;
Player.lastYPos = Player.newLastYPos;
System.out.println(TilesDrawn+" Tiles updated");
TilesDrawn = 0;
}

ld;dr: it's a lot more complicated x.x
  • 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 c4ooo

  • Super User
  • CW Contest II Winner
  • *
  • Join Date: Aug 2015
  • Location: 127.0.0.1
  • Posts: 947
  • Post Rating Ratio: +10/-2
  • Advanced forumer
  • Gender: Male
Re: Walrus Kingdom (former PocketWalrus)
« Reply #247 on: April 18, 2017, 01:27:45 am »
You can get rid of Math.round() and just cast to int ;)
Anyways, are you using openGL or Graphics2D?
I *might* be able to advise on how to optimize.

Also, if (data!=dataOld | ForceUpdate == true) could be:  if (data!=dataOld || ForceUpdate).

 


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