Post Reply 
Prime retro-gaming: trek!
08-29-2024, 03:11 PM
Post: #3
RE: Prime retro-gaming: trek!
In addition to Piotr's comment, I'd like to add this teaser. Simply copy the code to the Python app. It doesn't do fancy things, but shows how things could be displayed --- the Prime is a graphing calculator after all.

Code:
import hpprime as hp
from graphic import *
bg = 0xf8f8f8 #background color 

hp.eval('print') 
hp.fillrect(0,0,0,320,240,bg,cyan)
Width = 20 
hMargin = 5; vMargin = 15
def string(arg):
    return '"' + str(arg) +'"'
    
def RGB(r,g,b):
    return (r*256+g)*256+b
    
def strip(arg): 
    return str(arg)[1:-1]

def TxtOut(t,x,y,f,c,*args):
    if len(args)>2:
       raise(SyntaxError("too many arguments"))
    if True in [isinstance(i,list) for i in t]:
       raise(TypeError("can't convert 'list' object to str implicitly")) 
    parms=(int(x),int(y),int(f),int(c))
    if len(args)>0:parms+=(int(args[0]),)
    if len(args)>1:parms+=(int(args[1]),)
    return hp.eval('TEXTOUT_P('+string(t)+','+strip(parms)+')')       

def TxtRight(t,x,y,f,c,*args):
   x -= hp.eval('TEXTSIZE('+string(t)+','+str(f)+')')[0]
   TxtOut(t,x,y,f,c,*args)

def TxtCenter(t,x,y,f,c,*args):
   x  -=  (hp.eval('TEXTSIZE('+string(t)+','+str(f)+')')[0])/2
   TxtOut(t,x,y,f,c,*args)
 
def PutSymb(Symb,x,y):
    x = hMargin+(x-1)*Width+Width/2
    y = vMargin+(y-1)*Width+Width/2
    hp.circle(0,x,y,1,bg)
    hp.pixon(0,x,y,bg)
    TxtOut(Symb,x-Width/4,y-Width/4,2,0)
     
def DrawGrid():
    hp.fillrect(0,hMargin-1,vMargin-1,Width*8+2,Width*8+2,0,bg)
    xy0=[(hMargin+x*Width+Width/2,vMargin+y*Width+Width/2) 
          for x in range(8) for y in range(8)]
    for xy in xy0:
        x,y = xy
        hp.circle(0,x,y,1,0)
        hp.pixon(0,x,y,0)
    TxtOut("Sector 8-8 in Qadrant 5-2",hMargin,0,2,0)
    
DrawGrid()

hp.eval('DRAWMENU("Course","Phaser","Torpedo","SR Scan","LR Scan","Report")')

PutSymb("E",8,8)
PutSymb("✵",5,5)
PutSymb("B",4,4)
PutSymb("K",2,6)
PutSymb("✵",1,1)
PutSymb("K",4,3)
TxtOut("Condition Yellow",200,10,3,0,200,yellow)
TxtOut("Energie: 290",200,30,3,0,200,red)


hp.eval("wait")

Hope you're addicted.

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Prime retro-gaming: trek! - ab3ap - 08-27-2024, 12:16 AM
RE: Prime retro-gaming: trek! - komame - 08-28-2024, 07:57 PM
RE: Prime retro-gaming: trek! - ab3ap - 08-29-2024, 04:53 PM
RE: Prime retro-gaming: trek! - jte - 08-30-2024, 01:08 AM
RE: Prime retro-gaming: trek! - Guenter Schink - 08-29-2024 03:11 PM
RE: Prime retro-gaming: trek! - ab3ap - 08-29-2024, 04:59 PM
RE: Prime retro-gaming: trek! - jte - 08-30-2024, 12:58 AM
RE: Prime retro-gaming: trek! - ab3ap - 08-30-2024, 08:49 PM
RE: Prime retro-gaming: trek! - matalog - 08-30-2024, 08:37 AM
RE: Prime retro-gaming: trek! - ab3ap - 08-30-2024, 08:59 PM
RE: Prime retro-gaming: trek! - komame - 08-30-2024, 10:34 PM
RE: Prime retro-gaming: trek! - komame - 08-31-2024, 08:59 PM
RE: Prime retro-gaming: trek! - ab3ap - 09-01-2024, 08:54 PM
RE: Prime retro-gaming: trek! - komame - 09-01-2024, 01:55 AM
RE: Prime retro-gaming: trek! - ab3ap - 09-06-2024, 01:10 AM
RE: Prime retro-gaming: trek! - komame - 09-02-2024, 04:43 PM
RE: Prime retro-gaming: trek! - ab3ap - 09-02-2024, 08:17 PM
RE: Prime retro-gaming: trek! - komame - 09-02-2024, 10:36 PM
RE: Prime retro-gaming: trek! - ab3ap - 09-03-2024, 01:08 PM
RE: Prime retro-gaming: trek! - ab3ap - 09-26-2024, 07:23 PM
RE: Prime retro-gaming: trek! - toml_12953 - 09-26-2024, 06:21 PM
RE: Prime retro-gaming: trek! - ab3ap - 09-26-2024, 07:36 PM
RE: Prime retro-gaming: trek! - ab3ap - 10-15-2024, 09:55 PM
RE: Prime retro-gaming: trek! - ab3ap - 10-22-2024, 12:20 PM
RE: Prime retro-gaming: trek! - komame - 10-22-2024, 01:05 PM



User(s) browsing this thread: 2 Guest(s)