Jump to content

Photo

This is my first game using intybasic: RunnerZ

intybasic runnerZ first

10 replies to this topic

#1 JosueCom OFFLINE  

JosueCom

    Space Invader

  • 14 posts
  • Location:Massachusetts

Posted Sun Dec 17, 2017 12:38 AM

The link to the game is https://github.com/J...ellivision_Game. I got introduced to IntyBasic and the forum by my computer science professor in college. I am currently a sophomore. Tell me what you think about it. Good? Bad? I have attached the rom file; Attached File  runnerZ.rom   10.56KB   66 downloads .



#2 JosueCom OFFLINE  

JosueCom

    Space Invader

  • Topic Starter
  • 14 posts
  • Location:Massachusetts

Posted Sun Dec 17, 2017 1:40 PM

How can I improve the animation? After a certain amount of time it becomes slower and slower.



#3 nanochess ONLINE  

nanochess

    Processorus Polyglotus

  • 5,800 posts
  • Coding something good
  • Location:Mexico City

Posted Sun Dec 17, 2017 3:58 PM

The modulus operator isn't so fast in IntyBASIC because it's implemented using repetitive substraction.

 

As your #univclock variable increases, the modulus operator takes longer in special for smaller modulus like 3.

 

I would suggest you to use powers of two for modulus.



#4 intvnut OFFLINE  

intvnut

    River Patroller

  • 3,235 posts
  • Location:@R6 (top of stack)

Posted Sun Dec 17, 2017 4:14 PM

I suspect the modulo operations you're using become slower and slower as #univclock increases.  There is no "divide" or "multiply" instruction on the machine, and so the cost of those operations changes as values get larger.

 

If you compile with the --jlp switch, it'll use an external hardware accelerator.  (This accelerator is built into the LTO Flash cartridge, and supported in jzIntv.  It's also available on my JLP cartridge boards.)

 

Alternately, if you have values that just increment modulo some value, you're better off dedicating some small 8 bit variables to those values and doing an explicit increment and test.

 

That is, rather than writing:

.

(#univclock % (7-dificulty))

.

Have some other variable that increments 0 .. 6-dificulty.  For example, if I called it 'diff_phase':  (Short for "difficulty phase'.)

.

diff_phase = diff_phase + 1
if diff_phase = (7-dificulty) then diff_phase = 0

.

This one will also get slower and slower and slower:

.

#univclock%3

.

I'd replace that with, say, "move_phase" (short for movement phase):

.

move_phase = move_phase + 1
if move_phase = 3 then move_phase = 0

.

Some of the modulos may be OK.  I believe IntyBASIC will replace modulo with a bitwise AND if you're computing modulo a power of 2.  So %8 ends up being the same as AND 7.  You can double check by looking at the compiler output.  Your BASIC source code will be interlisted with the corresponding assembly, making it easy to find what your code expands into.

 

 

Other minor things:

.

RAND%3

.

is better written as

.

RAND(3)

.

It might not be obvious from the generated assembly, but the latter is much faster.  The RAND%3 generates a loop that repeatedly subtracts 3 from the random seed.  That could iterate many, many times.  The RAND(3) calls "qs_mpy8".  That performs multiplication via the quarter square method, and takes ~50 cycles.  Compared to the repeated subtract method, it's actually much faster.

.

    ;[2] x = RAND%3
    SRCFILE "r.bas",2
    MVI _rand,R0
T1:
    SUBI #3,R0
    BC T1
    ADDI #3,R0
    MVO R0,V1
    ;[3] y = RAND(3)
    SRCFILE "r.bas",3
    MVII #3,R0
    MVI _rand,R1
    CALL qs_mpy8
    SWAP R0
    ANDI #255,R0
    MVO R0,V2

.

This comment also applies to your other calls to RAND.

 

You also need to be a little careful with RAND:  RAND only updates once per frame.  If you need distinct random numbers, use RANDOM() instead.  The range on both is limited 0..255, so if you need larger random numbers, you need to do something different.  (At first, I thought you might have an issue in chooseObject, but on closer inspection, you don't.)

 

This sets all the array values to 0.  I suspect you did not want to /100 here.  You do the right thing in determinelevel, so I suspect this is stale code?

.

percentage(0) = 48/100
percentage(1) = 23/100
percentage(2) = 23/100
percentage(3) = 4/100
percentage(4) = 2/100

.

If you make the percentages cumulative, you can avoid the awkward math in chooseObject.  That is, you could do something like this:

.

percentage[0] = 48
percentage[1] = 23 + percentage[0]
percentage[2] = 23 + percentage[1]
percentage[3] = 4 + percentage[2]
percentage[4] = 2 + percentage[3]

.

Then your chooseObject routine can avoid all that addition:

.

chooseObject: procedure
	chance = RANDOM(percentage(4))
	if chance < percentage(0) then 'nothing chances
		chance = 0
	elseif chance < percentage(1) then 'rock chances
		chance = 1
	elseif chance < percentage(2) then 'coin chances
		chance = 2
	elseif chance < percentage(3) then 'apple chances
		chance = 3
	else 'Random powerup
		chance = RANDOM(3) + 4 'Powerup
	end if

	return
end

.

I'm not sure 'percentage' is a great name for that variable.  cum_obj_weight (cumulative object weight) is perhaps more descriptive.

 

If you can make the weights always sum to 128 or 256, you can make this even more efficient by eliminating percentage(4) and replacing RANDOM(percentage(4)) with RANDOM(256).  The computation for that is more efficient.  Basically, you'll just scale all your weights upwards by 2.56, and round creatively so they sum to 256.

 

Try tweaking those things, and see where you end up.  :-)


Edited by intvnut, Sun Dec 17, 2017 4:19 PM.


#5 mmarrero OFFLINE  

mmarrero

    Star Raider

  • 61 posts

Posted Sun Dec 17, 2017 8:46 PM

Good concept! it does need a few tweaks. It reminds me of Antarctic Adventure (Kojima was co-designer of sequel, Penguin adventure), and also somewhat of 80's Casio watch racing games, GD8, and GT6. I think 2d videogames are a great as an introduction to programming. There is a lot of material in the forums: great code, tutorials, documentation, tools, and advanced techniques.

 

I viewed the source code... very few comments. Some should've constants, for example, const ROCK=1. Code is very well organized and readable, but, I still prefer reading 1 comment than mentally interpreting 2 lines of code.

About gameplay, the 1st level starts OK, but later levels are too slow and too easy. The animated road can be white, text shouldn't flash, I recommend more obstacles, player should bump/shake when losing a life, and there should be more variety of object placement.



#6 JosueCom OFFLINE  

JosueCom

    Space Invader

  • Topic Starter
  • 14 posts
  • Location:Massachusetts

Posted Sun Dec 17, 2017 10:01 PM

Thank you for the feedback. I will add more comments. I was not able to work on the game much do to the finals exams. I will work on it as soon as possible. 

 

I do not have more cards available. So, I can only change the colors of the ones I have. I am going to work on a new version with more functionalities. I am also working on the animation with the previous suggestions. What do you suggest to make the levels harder? 

 

Good concept! it does need a few tweaks. It reminds me of Antarctic Adventure (Kojima was co-designer of sequel, Penguin adventure), and also somewhat of 80's Casio watch racing games, GD8, and GT6. I think 2d videogames are a great as an introduction to programming. There is a lot of material in the forums: great code, tutorials, documentation, tools, and advanced techniques.

 

I viewed the source code... very few comments. Some should've constants, for example, const ROCK=1. Code is very well organized and readable, but, I still prefer reading 1 comment than mentally interpreting 2 lines of code.

About gameplay, the 1st level starts OK, but later levels are too slow and too easy. The animated road can be white, text shouldn't flash, I recommend more obstacles, player should bump/shake when losing a life, and there should be more variety of object placement.



#7 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 12,032 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Wed Dec 20, 2017 11:00 AM

I got introduced to IntyBasic and the forum by my computer science professor in college.

 

I am absolutely curious to know who your Computer Science professor is.  He or she must be a most interesting person. :)

 

   -dZ.



#8 JosueCom OFFLINE  

JosueCom

    Space Invader

  • Topic Starter
  • 14 posts
  • Location:Massachusetts

Posted Wed Dec 20, 2017 2:15 PM

I have updated the game. This is version 1 of it. The GitHub link is the same as above: https://github.com/JosueCom/RUNNERZ

Attached File  runnerZ.rom   12.06KB   60 downloads

 

Things that the player can do (cont1):

 

- jump = up button

- move to the right = right button

- move to the left = left button

- pause = pause key (have not test it because I could not find the key)


Edited by JosueCom, Wed Dec 20, 2017 7:24 PM.


#9 First Spear OFFLINE  

First Spear

    Stargunner

  • 1,369 posts
  • Location:Somewhere in Uptown

Posted Thu Dec 21, 2017 10:00 PM

First cut at some title screen music

 

Spoiler

 

 

The link to the game is https://github.com/J...ellivision_Game. I got introduced to IntyBasic and the forum by my computer science professor in college. I am currently a sophomore. Tell me what you think about it. Good? Bad? I have attached the rom file; attachicon.gifrunnerZ.rom .



#10 intvnut OFFLINE  

intvnut

    River Patroller

  • 3,235 posts
  • Location:@R6 (top of stack)

Posted Mon Dec 25, 2017 7:34 PM

 

I am absolutely curious to know who your Computer Science professor is.  He or she must be a most interesting person. :)

 

The professor actually contacted me in order to acquire an LTO Flash! to run the projects with.  Sounds really awesome if you ask me.  :-)

 

I'll leave it to him to pipe up if he'd like to "out" himself.

 

The course syllabus for the class (if I found the right one) goes roughly: bits, fundamental data types, combinatorial logic, sequential logic, Von Neumann architecture, assembly language, I/O, interpreters, and then compilers.  The course appears to have a strong assembly language component with the LC-3 educational architecture.

 

That's quite the tour de force, if you ask me.



#11 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 12,032 posts
  • The P-Machinery AGE is almost here!
  • Location:NC, USA

Posted Tue Dec 26, 2017 5:18 AM

 

The professor actually contacted me in order to acquire an LTO Flash! to run the projects with.  Sounds really awesome if you ask me.  :-)

 

I'll leave it to him to pipe up if he'd like to "out" himself.

 

The course syllabus for the class (if I found the right one) goes roughly: bits, fundamental data types, combinatorial logic, sequential logic, Von Neumann architecture, assembly language, I/O, interpreters, and then compilers.  The course appears to have a strong assembly language component with the LC-3 educational architecture.

 

That's quite the tour de force, if you ask me.

 

Wow... that is awesome.  It almost makes me want to go back to college.  Almost.  Hehehe...

 

My Computer Science curriculum was heavy on the architecture, hardware, and electronics side (this was the late 80s and early 90s), while the software component was rather bare.  It started with Introduction to BASIC for general computer architecture, then Data Structures in Pascal, Structured Programming in Cobol, and a hint of x86 Assembly to introduce Von Neumann architecture.  My C programming exposure came from an elective class in the Business Major curriculum ("Programming of Information Systems"; MBAs had a chance at C, CS majors had mostly Pascal and Cobol), and I had to tap the Electrical Engineering curriculum to get a taste of discrete circuits and sequential/combinatorial logic.

 

My schedule was a hodge-podge of courses from many different curricula, taken as elective classes.

 

I hear about syllabi like you mentioned and I get very excited. :)

 

    -dZ.







Also tagged with one or more of these keywords: intybasic, runnerZ, first

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users